draw_spectral#

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

使用谱二维布局绘制图 G

这是一个等同于以下操作的便捷函数:

nx.draw(G, pos=nx.spectral_layout(G), **kwargs)

有关如何确定节点位置的更多信息,请参阅 spectral_layout

参数:
G

一个 networkx 图

kwargs可选关键字参数

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

另请参阅

spectral_layout()

注意

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

>>> G = nx.complete_graph(5)
>>> pos = nx.spectral_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.path_graph(5)
>>> nx.draw_spectral(G)