| graph_draw (g[, pos, size, 15), ...]) | Draw a graph using graphviz. |
| arf_layout (g[, weight, d, a, dt, ...]) | Calculate the ARF spring-block layout of the graph. |
| random_layout (g[, shape, pos, dim]) | Performs a random layout of the graph. |
Draw a graph using graphviz.
| Parameters: | g : Graph
pos : PropertyMap or tuple of PropertyMaps (optional, default: None)
size : tuple of scalars (optional, default: (15,15))
pin : bool (default: False)
layout : string (default: “neato”)
maxiter : int (default: None)
ratio : string or float (default: “fill”)
overlap : bool or string (default: “prism”)
sep : float (default: None)
splines : bool (default: False)
vsize : float, PropertyMap, or tuple (default: 0.1)
penwidth : float, PropertyMap or tuple (default: 1.0)
elen : float or PropertyMap (default: None)
gprops : dict (default: {})
vprops : dict (default: {})
eprops : dict (default: {})
vcolor : string or PropertyMap (default: None)
ecolor : string or PropertyMap (default: None)
vcmap : matplotlib.colors.Colormap (default: matplotlib.cm.jet)
vnorm : bool (default: True)
ecmap : matplotlib.colors.Colormap (default: matplotlib.cm.jet)
enorm : bool (default: True)
output : string (default: “”)
output_format : string (default: “auto”)
returngv : bool (default: False)
fork : bool (default: False)
return_bitmap : bool (default: False)
|
|---|---|
| Returns: | pos : PropertyMap
gv : gv.digraph or gv.graph (optional, only if returngv == True)
|
Notes
This function is a wrapper for the [graphviz] python routines. Extensive additional documentation for the graph, vertex and edge properties is available at: http://www.graphviz.org/doc/info/attrs.html.
References
| [graphviz] | http://www.graphviz.org |
Examples
>>> from numpy import *
>>> from numpy.random import seed, zipf
>>> seed(42)
>>> g = gt.random_graph(1000, lambda: min(zipf(2.4), 40),
... lambda i,j: exp(abs(i-j)), directed=False)
>>> # extract largest component
>>> comp = gt.label_components(g)
>>> h = gt.vertex_hist(g, comp)
>>> max_comp = h[1][list(h[0]).index(max(h[0]))]
>>> g.remove_vertex_if(lambda v: comp[v] != max_comp)
>>>
>>> deg = g.degree_property_map("out")
>>> deg.get_array()[:] = 2*(sqrt(deg.get_array()[:])*0.5 + 0.4)
>>> ebet = gt.betweenness(g)[1]
>>> ebet.get_array()[:] *= 4000
>>> ebet.get_array()[:] += 10
>>> gt.graph_draw(g, vsize=deg, vcolor=deg, elen=10, ecolor=ebet,
... penwidth=ebet, overlap="prism", output="graph-draw.png")
<...>
Kamada-Kawai force-directed layout of a graph with a power-law degree distribution, and dissortative degree correlation. The vertex size and color indicate the degree, and the edge color and width the edge betweeness centrality.
Calculate the ARF spring-block layout of the graph.
| Parameters: | g : Graph
weight : PropertyMap (optional, default: None)
d : float (optional, default: 0.1)
a : float (optional, default: 10)
dt : float (optional, default: 0.001)
epsilon : float (optional, default: 1e-6)
max_iter : int (optional, default: 1000)
pos : PropertyMap (optional, default: None)
dim : int (optional, default: 2)
|
|---|---|
| Returns: | pos : A vector vertex property map
|
Notes
This algorithm is defined in [geipel-self-organization-2007], and has complexity O(V^2).
References
| [geipel-self-organization-2007] | Markus M. Geipel, “Self-Organization applied to Dynamic Network Layout” , International Journal of Modern Physics C vol. 18, no. 10 (2007), pp. 1537-1549, arXiv:0704.1748v5 |
Examples
>>> from numpy.random import seed, zipf
>>> seed(42)
>>> g = gt.random_graph(100, lambda: 3, directed=False)
>>> t = gt.min_spanning_tree(g)
>>> g.set_edge_filter(t)
>>> pos = gt.graph_draw(g, output=None) # initial configuration
>>> pos = gt.arf_layout(g, pos=pos, max_iter=0)
>>> gt.graph_draw(g, pos=pos, pin=True, output="graph-draw-arf.png")
<...>
ARF layout of a minimum spanning tree of a random graph.
Performs a random layout of the graph.
| Parameters: | g : Graph
shape : tuple (optional, default: None)
pos : PropertyMap (optional, default: None)
dim : int (optional, default: 2)
|
|---|---|
| Returns: | pos : A vector vertex property map
|
Notes
This algorithm has complexity O(V).