draw_shell

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

Draw networkx graph G with shell layout.

This is a convenience function equivalent to:

nx.draw(G, pos=nx.shell_layout(G, nlist=nlist), **kwargs)
Parameters
Ggraph

A networkx graph

nlistlist of list of nodes, optional

A list containing lists of nodes representing the shells. Default is None, meaning all nodes are in a single shell. See shell_layout for details.

kwargsoptional keywords

See draw_networkx for a description of optional keywords.

See also

shell_layout()

Notes

The layout is computed each time this function is called. For repeated drawing it is much more efficient to call shell_layout directly and reuse the result:

>>> 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")