igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] Graph Visualization


From: Tamas Nepusz
Subject: Re: [igraph] Graph Visualization
Date: Fri, 6 Jun 2008 21:38:33 +0200

Hi Lorenzo,

IMHO the first step in creating a decent visualization is to find a layout of the vertices that pleases the eye. If your vertices are particles in 2D or 3D space, you might use their coordinates directly; if not, a good choice is the DrL layout algorithm, which is unfortunately not yet implemented in igraph (although you can create a Python wrapper that saves the graph in edgelist format, passes it to DrL by directly calling its executable and then parse the resulting layout file to obtain a Layout object).
See the following page for the source code of DrL:
http://www.cs.sandia.gov/~smartin/software.html

After having obtained a satisfactory layout, you can use the plot command in Python to plot the graph:

plot(g, layout=lo)

where `g' is the graph being visualized and `lo' is the Layout object or the name of a built-in visualization algorithm (see help(Graph.layout) for a list of known layouts). This draws the graph according to the layout in a temporary .png file and opens it in the image viewer of your OS. Vertex sizes can be controlled by assigning to the "size" vertex attribute, colors can be controlled by assigning to the "color" vertex attribute. The "color" attribute may either contain color specifications in "#rrggbb" format (as in HTML), or an integer between 0 and 255 which refers to the current color palette of the plot (see help(Palette), help(GradientPalette), help(AdvancedGradientPalette) and the "palette" keyword argument of plot).

Plots can also be saved permanently, e.g.:

g = Graph.Tree(156, 5)
plot(g, "graph.png", layout="fruchterman_reingold", vertex_label=None)


--
Tamas




reply via email to

[Prev in Thread] Current Thread [Next in Thread]