networkx 2.8.2 Pypi GitHub Homepage
Other Docs
ParametersBackRef

Set operations act on the nodes without considering data. Iteration is over nodes. Node data can be looked up like a dict. Use NodeDataView to iterate over node data or to specify a data attribute for lookup. NodeDataView is created by calling the NodeView.

Parameters

graph : NetworkX graph-like class

A NodeView class to act as G.nodes for a NetworkX Graph

Examples

>>> G = nx.path_graph(3)
... NV = G.nodes()
... 2 in NV True
>>> for n in NV:
...  print(n) 0 1 2
>>> assert NV & {1, 2, 3} == {1, 2}
>>> G.add_node(2, color="blue")
... NV[2] {'color': 'blue'}
>>> G.add_node(8, color="red")
... NDV = G.nodes(data=True)
... (2, NV[2]) in NDV True
>>> for n, dd in NDV:
...  print((n, dd.get("color", "aqua"))) (0, 'aqua') (1, 'aqua') (2, 'blue') (8, 'red')
>>> NDV[2] == NV[2]
True
>>> NVdata = G.nodes(data="color", default="aqua")
... (2, NVdata[2]) in NVdata True
>>> for n, dd in NVdata:
...  print((n, dd)) (0, 'aqua') (1, 'aqua') (2, 'blue') (8, 'red')
>>> NVdata[2] == NV[2]  # NVdata gets 'color', NV gets datadict
False
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

networkx.classes.graph.Graph.remove_nodes_from networkx.classes.reportviews.NodeView networkx.classes.digraph.DiGraph.clear_edges networkx.classes.digraph.DiGraph.remove_nodes_from networkx.algorithms.operators.binary.union networkx.classes.digraph.DiGraph.clear networkx.classes.reportviews.NodeView.data networkx.algorithms.operators.binary.compose networkx.algorithms.bipartite.edgelist.parse_edgelist networkx.algorithms.link_prediction.cn_soundarajan_hopcroft networkx.classes.graph.Graph.clear_edges networkx.classes.graph.Graph.clear networkx.generators.classic.complete_graph networkx.algorithms.node_classification.lgc.local_and_global_consistency networkx.algorithms.node_classification.hmn.harmonic_function networkx.algorithms.bipartite.basic.color networkx.algorithms.operators.binary.intersection networkx.algorithms.operators.binary.disjoint_union networkx.algorithms.operators.binary.full_join

Local connectivity graph

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


GitHub : /networkx/classes/reportviews.py#115
type: <class 'abc.ABCMeta'>
Commit: