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

Method __init__

python/graphscope/nx/classes/digraph.py:243–302  ·  view source on GitHub ↗
(self, incoming_graph_data=None, default_label=None, **attr)

Source from the content-addressed store, hash-verified

241
242 @patch_docstring(Graph.__init__)
243 def __init__(self, incoming_graph_data=None, default_label=None, **attr):
244 self.graph_attr_dict_factory = self.graph_attr_dict_factory
245 self.node_dict_factory = self.node_dict_factory
246 self.adjlist_outer_dict_factory = self.adjlist_outer_dict_factory
247 self.cache = self.graph_cache_factory(self)
248
249 # init node and adj (must be after cache)
250 self.graph = self.graph_attr_dict_factory()
251 self._node = self.node_dict_factory(self)
252 self._adj = self.adjlist_outer_dict_factory(self)
253 self._succ = self._adj
254 self._pred = self.adjlist_outer_dict_factory(self, pred=True)
255
256 self._key = None
257 self._op = None
258 self._graph_type = self._graph_type
259 self._schema = GraphSchema()
260
261 # cache for add_node and add_edge
262 self._add_node_cache = []
263 self._add_edge_cache = []
264 self._remove_node_cache = []
265 self._remove_edge_cache = []
266
267 create_empty_in_engine = attr.pop(
268 "create_empty_in_engine", True
269 ) # a hidden parameter
270 self._distributed = attr.pop("dist", False)
271 if incoming_graph_data is not None and self._is_gs_graph(incoming_graph_data):
272 # convert from gs graph always use distributed mode
273 self._distributed = True
274 if self._session is None:
275 self._session = get_session_by_id(incoming_graph_data.session_id)
276 self._default_label = default_label
277 self._default_label_id = -1
278
279 if self._session is None:
280 self._session = get_default_session()
281
282 if not self._is_gs_graph(incoming_graph_data) and create_empty_in_engine:
283 graph_def = init_empty_graph_in_engine(
284 self, self.is_directed(), self._distributed
285 )
286 self._key = graph_def.key
287
288 # attempt to load graph with data
289 if incoming_graph_data is not None:
290 to_networkx_graph(incoming_graph_data, create_using=self)
291 self.cache.warmup()
292
293 # load graph attributes (must be after to_networkx_graph)
294 self.graph.update(attr)
295 self._saved_signature = self.signature
296 self._is_client_view = False
297
298 # statically create the unload op
299 if self.op is None:
300 self._unload_op = None

Callers

nothing calls this directly

Calls 10

is_directedMethod · 0.95
GraphSchemaClass · 0.90
get_session_by_idFunction · 0.90
get_default_sessionFunction · 0.90
to_networkx_graphFunction · 0.90
_is_gs_graphMethod · 0.80
popMethod · 0.45
warmupMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected