NetworkX

Table Of Contents

Previous topic

networkx.read_sparse6_list

Next topic

networkx.draw

Quick search

Drawing

Matplotlib

Draw networks with matplotlib (pylab).

References:
draw (G[, pos, ax, hold, \*\*kwds) Draw the graph G with matplotlib (pylab).
draw_networkx (G, pos[, with_labels, \*\*kwds) Draw the graph G with given node positions pos
draw_networkx_nodes (G, pos[, nodelist, node_size, node_color, node_shape, alpha, cmap, vmin, vmax, ax, linewidths, \*\*kwds) Draw nodes of graph G
draw_networkx_edges (G, pos[, edgelist, width, edge_color, style, alpha, edge_cmap, edge_vmin, edge_vmax, ax, arrows, \*\*kwds) Draw the edges of the graph G
draw_networkx_labels (G, pos[, labels, font_size, font_color, font_family, font_weight, alpha, ax, \*\*kwds) Draw node labels on the graph G
draw_circular (G, \*\*kwargs) Draw the graph G with a circular layout
draw_random (G, \*\*kwargs) Draw the graph G with a random layout.
draw_spectral (G, \*\*kwargs) Draw the graph G with a spectral layout.
draw_spring (G, \*\*kwargs) Draw the graph G with a spring layout
draw_shell (G, \*\*kwargs) Draw networkx graph with shell layout
draw_graphviz (G[, prog, \*\*kwargs) Draw networkx graph with graphviz layout

Graphviz AGraph (dot)

Interface to pygraphviz AGraph class.

Usage

>>> G=nx.complete_graph(5)
>>> A=nx.to_agraph(G)
>>> H=nx.from_agraph(A)

Pygraphviz: http://networkx.lanl.gov/pygraphviz

from_agraph (A[, create_using]) Return a NetworkX Graph or DiGraph from a pygraphviz graph.
to_agraph (N[, graph_attr, node_attr, ...]) Return a pygraphviz graph from a NetworkX graph N.
write_dot (G, path) Write NetworkX graph G to Graphviz dot format on path.
read_dot (path[, create_using]) Return a NetworkX XGraph or XdiGraph from a dot file on path.
graphviz_layout (G[, prog, root, args]) Create layout using graphviz. Returns a dictionary of positions keyed by node.
pygraphviz_layout (G[, prog, root, args]) Create layout using pygraphviz and graphviz. Returns a dictionary of positions keyed by node.

Graphviz with pydot

Import and export NetworkX graphs in Graphviz dot format using pydot.

Either this module or nx_pygraphviz can be used to interface with graphviz.

References:
from_pydot (P) Return a NetworkX Graph or DiGraph from a pydot graph.
to_pydot (N[, graph_attr, node_attr, ...]) Return a pydot graph from a NetworkX graph N.
write_dot (G, path) Write NetworkX graph G to Graphviz dot format on path.
read_dot (path[, create_using]) Return a NetworkX XGraph or XdiGraph from a dot file on path.
graphviz_layout (G[, prog, root, args]) Create layout using graphviz. Returns a dictionary of positions keyed by node.
pydot_layout (G[, prog, root, \*\*kwds) Create layout using pydot and graphviz. Returns a dictionary of positions keyed by node.

Graph Layout

Node positioning algorithms for graph drawing.

circular_layout (G[, dim]) Circular layout.
random_layout (G[, dim]) Random layout.
shell_layout (G[, nlist, dim]) Shell layout. Crude version that doesn’t try to minimize edge crossings.
spring_layout (G[, iterations, dim, ...]) Spring force model layout
spectral_layout (G[, dim, vpos, iterations, ...]) Return the position vectors for drawing G using spectral layout.