draw_random#

draw_random(G, **kwargs)[source]#

使用随机布局绘制图 G

这是一个便捷函数,等同于

nx.draw(G, pos=nx.random_layout(G), **kwargs)
参数:
G

一个 NetworkX 图

kwargs可选关键字

有关可选关键字的说明,请参阅 draw_networkx

另请参阅

random_layout()

备注

每次调用此函数时都会计算布局。对于重复绘图,直接调用 random_layout 并重用结果会效率高得多。

>>> G = nx.complete_graph(5)
>>> pos = nx.random_layout(G)
>>> nx.draw(G, pos=pos)  # Draw the original graph
>>> # Draw a subgraph, reusing the same node positions
>>> nx.draw(G.subgraph([0, 1, 2]), pos=pos, node_color="red")

示例

>>> G = nx.lollipop_graph(4, 3)
>>> nx.draw_random(G)