restricted_view(G, nodes, edges)
The resulting subgraph filters out node nodes
and edges edges
. Filtered out nodes also filter out any of their edges.
To create a mutable subgraph with its own copies of nodes edges and attributes use :None:None:`subgraph.copy()`
or :None:None:`Graph(subgraph)`
If you create a subgraph of a subgraph recursively you may end up with a chain of subgraph views. Such chains can get quite slow for lengths near 15. To avoid long chains, try to make your subgraph based on the original graph. We do not rule out chains programmatically so that odd cases like an edge_subgraph
of a restricted_view
can be created.
An iterable of nodes. Nodes not present in G
are ignored.
An iterable of edges. Edges not present in G
are ignored.
A read-only restricted view of G
filtering out nodes and edges. Changes to G
are reflected in the view.
Returns a view of G
with hidden nodes and edges.
>>> G = nx.path_graph(5)
... H = nx.restricted_view(G, [0], [(1, 2), (3, 4)])
... list(H.nodes) [1, 2, 3, 4]
>>> list(H.edges) [(2, 3)]See :
The following pages refer to to this document either explicitly or contain code examples using this.
networkx.classes.function.restricted_view
networkx.classes.function.edge_subgraph
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them