draw_shell#

draw_shell(G, nlist=None, **kwargs)[source]#

使用 shell 布局绘制 networkx 图 G

这是一个方便的函数,等价于

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

一个 networkx 图

nlist由节点列表组成的列表,可选

一个包含节点列表的列表,代表壳层。默认值为 None,表示所有节点都在一个壳层中。详见 shell_layout

kwargs可选关键字参数

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

另请参见

shell_layout()

注意

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

>>> G = nx.complete_graph(5)
>>> pos = nx.shell_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(4)
>>> shells = [[0], [1, 2, 3]]
>>> nx.draw_shell(G, nlist=shells)