python复杂网络库networkx:绘图draw

时间:2023-02-02 07:56:53

http://blog.csdn.net/pipisorry/article/details/54291831

networkx使用matplotlib绘制函数

draw(G[, pos, ax, hold]) Draw the graph G with Matplotlib.
draw_networkx(G[, pos, arrows, with_labels]) Draw the graph G using Matplotlib.
draw_networkx_nodes(G, pos[, nodelist, ...]) Draw the nodes of the graph G.
draw_networkx_edges(G, pos[, edgelist, ...]) Draw the edges of the graph G.
draw_networkx_labels(G, pos[, labels, ...]) Draw node labels on the graph G.
draw_networkx_edge_labels(G, pos[, ...]) Draw edge labels.
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]) Draw networkx graph with graphviz layout.

networkx使用Graphviz AGraph (dot)绘制函数

from_agraph(A[, create_using]) Return a NetworkX Graph or DiGraph from a PyGraphviz graph.
to_agraph(N) 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) Return a NetworkX graph from a dot file on path.
graphviz_layout(G[, prog, root, args]) Create node positions for G using Graphviz.

pygraphviz_layout(G[, prog, root, args])

Create node positions for G using Graphviz.

networkx使用Graphviz with pydot绘制函数

from_pydot(P) Return a NetworkX graph from a Pydot graph.
to_pydot(N[, strict]) 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) Return a NetworkX MultiGraph or MultiDiGraph from a dot file on path.
graphviz_layout(G[, prog, root]) Create node positions using Pydot and Graphviz.
pydot_layout(G[, prog, root]) Create node positions using Pydot and Graphviz.

图布局Graph Layout

circular_layout(G[, dim, scale, center]) Position nodes on a circle.
fruchterman_reingold_layout(G[, dim, k, ...]) Position nodes using Fruchterman-Reingold force-directed algorithm.
random_layout(G[, dim, scale, center]) Position nodes uniformly at random.
shell_layout(G[, nlist, dim, scale, center]) Position nodes in concentric circles.
spring_layout(G[, dim, k, pos, fixed, ...]) Position nodes using Fruchterman-Reingold force-directed algorithm.
spectral_layout(G[, dim, weight, scale, center]) Position nodes using the eigenvectors of the graph Laplacian.

皮皮blog



networkx绘图示例

def drawGraph(fg, title='weighted_graph'):    import matplotlib.pyplot as plt    import networkx as nx    pos = nx.spring_layout(fg)    nx.draw_networkx_nodes(fg, pos, node_shape='.', node_size=20)    nx.draw_networkx_edges(fg, pos)    nx.draw_networkx_labels(fg, pos)    nx.draw_networkx_edge_labels(fg, pos, edge_labels=nx.get_edge_attributes(fg, 'weight'))    plt.savefig(os.path.join(CWD, '../PGT/middlewares/' + title + '.png'))    plt.show()

from: http://blog.csdn.net/pipisorry/article/details/54291831

ref: [networkx reference]

[Drawing]