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

Function get_node_data

python/graphscope/nx/classes/cache.py:447–487  ·  view source on GitHub ↗

Returns the attribute dictionary of node n. This is identical to `G[n]`. Parameters ---------- n : nodes Returns ------- node_dict : dictionary The node attribute dictionary. Examples -------- >>> G = nx.path_graph(4) # or DiGraph etc >>> G[0]

(graph, n)

Source from the content-addressed store, hash-verified

445
446
447def get_node_data(graph, n):
448 """Returns the attribute dictionary of node n.
449
450 This is identical to `G[n]`.
451
452 Parameters
453 ----------
454 n : nodes
455
456 Returns
457 -------
458 node_dict : dictionary
459 The node attribute dictionary.
460
461 Examples
462 --------
463 >>> G = nx.path_graph(4) # or DiGraph etc
464 >>> G[0]
465 {}
466
467 Warning: Assigning to `G[n]` is not permitted.
468 But it is safe to assign attributes `G[n]['foo']`
469
470 >>> G[0]['weight'] = 7
471 >>> G[0]['weight']
472 7
473
474 >>> G = nx.path_graph(4) # or DiGraph etc
475 >>> G.get_node_data(0, 1)
476 {}
477
478 """
479 if graph.graph_type == graph_def_pb2.ARROW_PROPERTY:
480 n = graph._convert_to_label_id_tuple(n)
481 op = dag_utils.report_graph(
482 graph,
483 types_pb2.NODE_DATA,
484 node=json.dumps(n).encode("utf-8", errors="ignore"),
485 )
486 archive = op.eval()
487 return msgpack.loads(archive.get_bytes(), use_list=False)

Callers 2

set_node_attributesFunction · 0.90
get_node_attrMethod · 0.85

Calls 4

encodeMethod · 0.45
evalMethod · 0.45
get_bytesMethod · 0.45

Tested by

no test coverage detected