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

Method set_node_data

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

Set data of node. Parameters ---------- n : node node can be int, str, float, tuple, bool hashable Python object which is existed in graph. data : dict data to set to n See Also -------- set_edge_data : set data of edg

(self, n, data)

Source from the content-addressed store, hash-verified

1076
1077 @clear_mutation_cache
1078 def set_node_data(self, n, data):
1079 """Set data of node.
1080
1081 Parameters
1082 ----------
1083 n : node
1084 node can be int, str, float, tuple, bool hashable Python object which is existed in graph.
1085 data : dict
1086 data to set to n
1087
1088 See Also
1089 --------
1090 set_edge_data : set data of edge
1091
1092 Notes
1093 -----
1094 the method is called when to set_items in NodeAttr
1095
1096 Examples
1097 --------
1098 >>> G = nx.Graph() # or DiGraph
1099 >>> G.add_node(1)
1100 >>> dd = {'weight': 3}
1101 >>> G.nodes[1] = dd # call G.set_node_data(1, dd)
1102 >>> G.nodes[1]
1103 {'weight': 3}
1104
1105 """
1106 self._convert_arrow_to_dynamic()
1107
1108 node = json.dumps(((n, data),), option=json.OPT_SERIALIZE_NUMPY)
1109 self._op = dag_utils.modify_vertices(self, types_pb2.NX_UPDATE_NODES, node)
1110 self._op.eval(leaf=False)
1111 self.cache.clear_node_attr_cache()
1112
1113 @clear_mutation_cache
1114 def update(self, edges=None, nodes=None):

Callers 7

__setitem__Method · 0.80
__delitem__Method · 0.80
clearMethod · 0.80
updateMethod · 0.80
popMethod · 0.80
popitemMethod · 0.80
set_node_attributesFunction · 0.80

Calls 3

clear_node_attr_cacheMethod · 0.80
evalMethod · 0.45

Tested by

no test coverage detected