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

Method _from_nx_graph

python/graphscope/framework/graph.py:133–158  ·  view source on GitHub ↗

Create a gs graph from a nx graph. Args: g (:class:`graphscope.nx.graph`): A nx graph that contains graph data. Raises: RuntimeError: NX graph and gs graph not in the same session. TypeError: Convert a graph view of nx graph to gs graph.

(self, g)

Source from the content-addressed store, hash-verified

131 )
132
133 def _from_nx_graph(self, g):
134 """Create a gs graph from a nx graph.
135 Args:
136 g (:class:`graphscope.nx.graph`): A nx graph that contains graph data.
137
138 Raises:
139 RuntimeError: NX graph and gs graph not in the same session.
140 TypeError: Convert a graph view of nx graph to gs graph.
141
142 Returns: :class:`graphscope.framework.operation.Operation`
143 that will be used to construct a :class:`graphscope.Graph`
144
145 Examples:
146 .. code:: python
147
148 >>> import graphscope as gs
149 >>> nx_g = gs.nx.path_graph(10)
150 >>> gs_g = gs.Graph(nx_g)
151 """
152 if self.session_id != g.session_id:
153 raise RuntimeError(
154 "networkx graph and graphscope graph not in the same session."
155 )
156 if hasattr(g, "_graph"):
157 raise TypeError("graph view can not convert to gs graph")
158 return dag_utils.dynamic_to_arrow(g)
159
160 def _from_vineyard(self, vineyard_object):
161 """Load a graph from a already existed vineyard graph.

Callers 1

_resolve_opMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected