MCPcopy
hub / github.com/networkx/networkx / edges

Method edges

networkx/classes/graph.py:1388–1442  ·  view source on GitHub ↗

An EdgeView of the Graph as G.edges or G.edges(). edges(self, nbunch=None, data=False, default=None) The EdgeView provides set-like operations on the edge-tuples as well as edge attribute lookup. When called, it also provides an EdgeDataView object which allows cont

(self)

Source from the content-addressed store, hash-verified

1386
1387 @cached_property
1388 def edges(self):
1389 """An EdgeView of the Graph as G.edges or G.edges().
1390
1391 edges(self, nbunch=None, data=False, default=None)
1392
1393 The EdgeView provides set-like operations on the edge-tuples
1394 as well as edge attribute lookup. When called, it also provides
1395 an EdgeDataView object which allows control of access to edge
1396 attributes (but does not provide set-like operations).
1397 Hence, `G.edges[u, v]['color']` provides the value of the color
1398 attribute for edge `(u, v)` while
1399 `for (u, v, c) in G.edges.data('color', default='red'):`
1400 iterates through all the edges yielding the color attribute
1401 with default `'red'` if no color attribute exists.
1402
1403 Parameters
1404 ----------
1405 nbunch : single node, container, or all nodes (default= all nodes)
1406 The view will only report edges from these nodes.
1407 data : string or bool, optional (default=False)
1408 The edge attribute returned in 3-tuple (u, v, ddict[data]).
1409 If True, return edge attribute dict in 3-tuple (u, v, ddict).
1410 If False, return 2-tuple (u, v).
1411 default : value, optional (default=None)
1412 Value used for edges that don't have the requested attribute.
1413 Only relevant if data is not True or False.
1414
1415 Returns
1416 -------
1417 edges : EdgeView
1418 A view of edge attributes, usually it iterates over (u, v)
1419 or (u, v, d) tuples of edges, but can also be used for
1420 attribute lookup as `edges[u, v]['foo']`.
1421
1422 Notes
1423 -----
1424 Nodes in nbunch that are not in the graph will be (quietly) ignored.
1425 For directed graphs this returns the out-edges.
1426
1427 Examples
1428 --------
1429 >>> G = nx.path_graph(3) # or MultiGraph, etc
1430 >>> G.add_edge(2, 3, weight=5)
1431 >>> [e for e in G.edges]
1432 [(0, 1), (1, 2), (2, 3)]
1433 >>> G.edges.data() # default data is {} (empty dict)
1434 EdgeDataView([(0, 1, {}), (1, 2, {}), (2, 3, {'weight': 5})])
1435 >>> G.edges.data("weight", default=1)
1436 EdgeDataView([(0, 1, 1), (1, 2, 1), (2, 3, 5)])
1437 >>> G.edges([0, 3]) # only edges from these nodes
1438 EdgeDataView([(0, 1), (3, 2)])
1439 >>> G.edges(0) # only edges from node 0
1440 EdgeDataView([(0, 1)])
1441 """
1442 return EdgeView(self)
1443
1444 def get_edge_data(self, u, v, default=None):
1445 """Returns the attribute dictionary associated with edge (u, v).

Callers 15

test_edge_attrMethod · 0.95
test_edge_attr4Method · 0.95
test_fresh_copyMethod · 0.95
test_edge_attrMethod · 0.95
test_edge_attr2Method · 0.95
test_edge_attr3Method · 0.95
test_edge_attr4Method · 0.95

Calls 1

EdgeViewClass · 0.90

Tested by 15

test_edge_attrMethod · 0.76
test_edge_attr4Method · 0.76
test_fresh_copyMethod · 0.76
test_edge_attrMethod · 0.76
test_edge_attr2Method · 0.76
test_edge_attr3Method · 0.76
test_edge_attr4Method · 0.76