MCPcopy Create free account
hub / github.com/alibaba/GraphScope / edges

Method edges

python/graphscope/nx/classes/graph.py:1326–1380  ·  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

1324 @property
1325 @clear_mutation_cache
1326 def edges(self):
1327 """An EdgeView of the Graph as G.edges or G.edges().
1328
1329 edges(self, nbunch=None, data=False, default=None)
1330
1331 The EdgeView provides set-like operations on the edge-tuples
1332 as well as edge attribute lookup. When called, it also provides
1333 an EdgeDataView object which allows control of access to edge
1334 attributes (but does not provide set-like operations).
1335 Hence, `G.edges[u, v]['color']` provides the value of the color
1336 attribute for edge `(u, v)` while
1337 `for (u, v, c) in G.edges.data('color', default='red'):`
1338 iterates through all the edges yielding the color attribute
1339 with default `'red'` if no color attribute exists.
1340
1341 Parameters
1342 ----------
1343 nbunch : single node, container, or all nodes (default= all nodes)
1344 The view will only report edges incident to these nodes.
1345 data : string or bool, optional (default=False)
1346 The edge attribute returned in 3-tuple (u, v, ddict[data]).
1347 If True, return edge attribute dict in 3-tuple (u, v, ddict).
1348 If False, return 2-tuple (u, v).
1349 default : value, optional (default=None)
1350 Value used for edges that don't have the requested attribute.
1351 Only relevant if data is not True or False.
1352
1353 Returns
1354 -------
1355 edges : EdgeView
1356 A view of edge attributes, usually it iterates over (u, v)
1357 or (u, v, d) tuples of edges, but can also be used for
1358 attribute lookup as `edges[u, v]['foo']`.
1359
1360 Notes
1361 -----
1362 Nodes in nbunch that are not in the graph will be (quietly) ignored.
1363 For directed graphs this returns the out-edges.
1364
1365 Examples
1366 --------
1367 >>> G = nx.path_graph(3) # or DiGraph
1368 >>> G.add_edge(2, 3, weight=5)
1369 >>> [e for e in G.edges]
1370 [(0, 1), (1, 2), (2, 3)]
1371 >>> G.edges.data() # default data is {} (empty dict)
1372 EdgeDataView([(0, 1, {}), (1, 2, {}), (2, 3, {'weight': 5})])
1373 >>> G.edges.data("weight", default=1)
1374 EdgeDataView([(0, 1, 1), (1, 2, 1), (2, 3, 5)])
1375 >>> G.edges([0, 3]) # only edges incident to these nodes
1376 EdgeDataView([(0, 1), (3, 2)])
1377 >>> G.edges(0) # only edges incident to a single node (use G.adj[0]?)
1378 EdgeDataView([(0, 1)])
1379 """
1380 return EdgeView(self)
1381
1382 @clear_mutation_cache
1383 def get_edge_data(self, u, v, default=None):

Callers 15

test_data_typesMethod · 0.95
test_graphMethod · 0.95
test_weighted_graphMethod · 0.95
_relabel_inplaceFunction · 0.45
_relabel_copyFunction · 0.45
to_numpy_arrayFunction · 0.45
to_scipy_sparse_arrayFunction · 0.45
set_edge_attributesFunction · 0.45
test_reverse_copyMethod · 0.45
test_reverse_nocopyMethod · 0.45
test_reverse_hashableMethod · 0.45

Calls 1

EdgeViewClass · 0.90

Tested by 15

test_data_typesMethod · 0.76
test_graphMethod · 0.76
test_weighted_graphMethod · 0.76
test_reverse_copyMethod · 0.36
test_reverse_nocopyMethod · 0.36
test_reverse_hashableMethod · 0.36
test_correct_edgesMethod · 0.36
test_correct_edgesMethod · 0.36
test_edge_attr_dictMethod · 0.36
test_from_edgelistMethod · 0.36
assert_equalMethod · 0.36