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

Method get_edge_data

python/graphscope/nx/classes/graph.py:1383–1437  ·  view source on GitHub ↗

Returns the attribute dictionary associated with edge (u, v). This is identical to `G[u][v]` except the default is returned instead of an exception if the edge doesn't exist. Parameters ---------- u, v : nodes default: any Python object (default=Non

(self, u, v, default=None)

Source from the content-addressed store, hash-verified

1381
1382 @clear_mutation_cache
1383 def get_edge_data(self, u, v, default=None):
1384 """Returns the attribute dictionary associated with edge (u, v).
1385
1386 This is identical to `G[u][v]` except the default is returned
1387 instead of an exception if the edge doesn't exist.
1388
1389 Parameters
1390 ----------
1391 u, v : nodes
1392 default: any Python object (default=None)
1393 Value to return if the edge (u, v) is not found.
1394
1395 Returns
1396 -------
1397 edge_dict : dictionary
1398 The edge attribute dictionary.
1399
1400 Examples
1401 --------
1402 >>> G = nx.path_graph(4) # or DiGraph
1403 >>> G[0][1]
1404 {}
1405
1406 Warning: Assigning to `G[u][v]` is not permitted.
1407 But it is safe to assign attributes `G[u][v]['foo']`
1408
1409 >>> G[0][1]["weight"] = 7
1410 >>> G[0][1]["weight"]
1411 7
1412 >>> G[1][0]["weight"]
1413 7
1414
1415 >>> G = nx.path_graph(4) # or DiGraph
1416 >>> G.get_edge_data(0, 1) # default edge data is {}
1417 {}
1418 >>> e = (0, 1)
1419 >>> G.get_edge_data(*e) # tuple form
1420 {}
1421 >>> G.get_edge_data("a", "b", default=0) # edge not in graph, return 0
1422 0
1423 """
1424 if self.has_edge(u, v):
1425 if self.graph_type == graph_def_pb2.ARROW_PROPERTY:
1426 u = self._convert_to_label_id_tuple(u)
1427 v = self._convert_to_label_id_tuple(v)
1428 op = dag_utils.report_graph(
1429 self,
1430 types_pb2.EDGE_DATA,
1431 edge=json.dumps((u, v)),
1432 key="",
1433 )
1434 archive = op.eval()
1435 return json.loads(archive.get_bytes())
1436 else:
1437 return default
1438
1439 @property
1440 @clear_mutation_cache

Calls 4

has_edgeMethod · 0.95
evalMethod · 0.45
get_bytesMethod · 0.45