This densely packed View allows iteration over edges, data lookup like a dict and set operations on edges represented by node-tuples. In addition, edge data can be controlled by calling this object possibly creating an EdgeDataView. Typically edges are iterated over and reported as :None:None:`(u, v)`
node tuples or :None:None:`(u, v, key)`
node/key tuples for multigraphs. Those edge representations can also be using to lookup the data dict for any edge. Set operations also are available where those tuples are the elements of the set. Calling this object with optional arguments :None:None:`data`
, default
and keys
controls the form of the tuple (see EdgeDataView). Optional argument nbunch
allows restriction to edges only involving certain nodes.
If :None:None:`data is False`
(the default) then iterate over 2-tuples :None:None:`(u, v)`
. If :None:None:`data is True`
iterate over 3-tuples :None:None:`(u, v, datadict)`
. Otherwise iterate over :None:None:`(u, v, datadict.get(data, default))`
. For Multigraphs, if :None:None:`keys is True`
, replace :None:None:`u, v`
with :None:None:`u, v, key`
above.
A EdgeView class for edges of a Graph
>>> G = nx.path_graph(4)
... EV = G.edges()
... (2, 3) in EV True
>>> for u, v in EV:
... print((u, v)) (0, 1) (1, 2) (2, 3)
>>> assert EV & {(1, 2), (3, 4)} == {(1, 2)}
>>> EVdata = G.edges(data="color", default="aqua")
... G.add_edge(2, 3, color="blue")
... assert (2, 3, "blue") in EVdata
... for u, v, c in EVdata:
... print(f"({u}, {v}) has color: {c}") (0, 1) has color: aqua (1, 2) has color: aqua (2, 3) has color: blue
>>> EVnbunch = G.edges(nbunch=2)
... assert (2, 3) in EVnbunch
... assert (0, 1) not in EVnbunch
... for u, v in EVnbunch:
... assert u == 2 or v == 2
>>> MG = nx.path_graph(4, create_using=nx.MultiGraph)
... EVmulti = MG.edges(keys=True)
... (2, 3, 0) in EVmulti True
>>> (2, 3) in EVmulti # 2-tuples work even when keys is True True
>>> key = MG.add_edge(2, 3)See :
... for u, v, k in EVmulti:
... print((u, v, k)) (0, 1, 0) (1, 2, 0) (2, 3, 0) (2, 3, 1)
The following pages refer to to this document either explicitly or contain code examples using this.
networkx.classes.reportviews.EdgeDataView
networkx.convert_matrix.from_numpy_matrix
networkx.classes.digraph.DiGraph
networkx.readwrite.adjlist.parse_adjlist
networkx.classes.digraph.DiGraph.remove_node
networkx.algorithms.tree.coding.to_prufer_sequence
networkx.algorithms.assortativity.connectivity.average_degree_connectivity
networkx.classes.graph.Graph
networkx.classes.digraph.DiGraph.clear_edges
networkx.algorithms.bipartite.projection.weighted_projected_graph
networkx.algorithms.operators.binary.union
networkx.classes.digraph.DiGraph.clear
networkx.readwrite.edgelist.parse_edgelist
networkx.classes.reportviews.EdgeView
networkx.algorithms.bipartite.edgelist.read_edgelist
networkx.algorithms.operators.binary.compose
networkx.algorithms.bipartite.edgelist.parse_edgelist
networkx.convert_matrix.from_numpy_array
networkx.generators.classic.circulant_graph
networkx.classes.graph.Graph.clear_edges
networkx.classes.graph.Graph.clear
networkx.generators.line.line_graph
networkx.algorithms.bipartite.projection.collaboration_weighted_projected_graph
networkx.classes.multidigraph.MultiDiGraph
networkx.readwrite.edgelist.read_edgelist
networkx.algorithms.node_classification.lgc.local_and_global_consistency
networkx.algorithms.node_classification.hmn.harmonic_function
networkx.algorithms.bipartite.projection.generic_weighted_projected_graph
networkx.algorithms.bipartite.projection.overlap_weighted_projected_graph
networkx.classes.graph.Graph.remove_node
networkx.algorithms.tree.coding.from_prufer_sequence
networkx.algorithms.assortativity.neighbor_degree.average_neighbor_degree
networkx.classes.reportviews.OutEdgeView.data
networkx.classes.multigraph.MultiGraph
networkx.algorithms.operators.binary.intersection
networkx.algorithms.operators.binary.disjoint_union
networkx.algorithms.operators.binary.full_join
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