networkx 2.8.2 Pypi GitHub Homepage
Other Docs
NotesParametersReturnsBackRef
data(self, data=True, default=None, nbunch=None)

Notes

If data=False , returns an EdgeView without any edge data.

Parameters

data : bool or edge attribute key

If data=True , then the data view maps each edge to a dictionary containing all of its attributes. If data is a key in the edge dictionary, then the data view maps each edge to its value for the keyed attribute. In this case, if the edge doesn't have the attribute, the default value is returned.

default : object, default=None

The value used when an edge does not have a specific attribute

nbunch : container of nodes, optional (default=None)

Allows restriction to edges only involving certain nodes. All edges are considered by default.

Returns

dataview

Returns an EdgeDataView for undirected Graphs, OutEdgeDataView for DiGraphs, MultiEdgeDataView for MultiGraphs and OutMultiEdgeDataView for MultiDiGraphs.

Return a read-only view of edge data.

See Also

EdgeDataView
MultiEdgeDataView
OutEdgeDataView
OutMultiEdgeDataView

Examples

>>> G = nx.Graph()
... G.add_edges_from([
...  (0, 1, {"dist": 3, "capacity": 20}),
...  (1, 2, {"dist": 4}),
...  (2, 0, {"dist": 5})
... ])

Accessing edge data with data=True (the default) returns an edge data view object listing each edge with all of its attributes:

>>> G.edges.data()
EdgeDataView([(0, 1, {'dist': 3, 'capacity': 20}), (0, 2, {'dist': 5}), (1, 2, {'dist': 4})])

If data represents a key in the edge attribute dict, a dataview listing each edge with its value for that specific key is returned:

>>> G.edges.data("dist")
EdgeDataView([(0, 1, 3), (0, 2, 5), (1, 2, 4)])

nbunch can be used to limit the edges:

>>> G.edges.data("dist", nbunch=[0])
EdgeDataView([(0, 1, 3), (0, 2, 5)])

If a specific key is not found in an edge attribute dict, the value specified by default is used:

>>> G.edges.data("capacity")
EdgeDataView([(0, 1, 20), (0, 2, None), (1, 2, None)])

Note that there is no check that the data key is present in any of the edge attribute dictionaries:

>>> G.edges.data("speed")
EdgeDataView([(0, 1, None), (0, 2, None), (1, 2, None)])
See :

Back References

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

networkx.classes.graph.Graph networkx.classes.reportviews.OutEdgeView.data

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#1101
type: <class 'function'>
Commit: