MCPcopy
hub / github.com/dmlc/dgl / create_graph_index

Function create_graph_index

python/dgl/graph_index.py:1326–1359  ·  view source on GitHub ↗

Create a graph index object. Parameters ---------- graph_data : graph data Data to initialize graph. Same as networkx's semantics. readonly : bool Whether the graph structure is read-only.

(graph_data, readonly)

Source from the content-addressed store, hash-verified

1324
1325
1326def create_graph_index(graph_data, readonly):
1327 """Create a graph index object.
1328
1329 Parameters
1330 ----------
1331 graph_data : graph data
1332 Data to initialize graph. Same as networkx's semantics.
1333 readonly : bool
1334 Whether the graph structure is read-only.
1335 """
1336 if isinstance(graph_data, GraphIndex):
1337 # FIXME(minjie): this return is not correct for mutable graph index
1338 return graph_data
1339
1340 if graph_data is None:
1341 if readonly:
1342 raise Exception("can't create an empty immutable graph")
1343 return _CAPI_DGLGraphCreateMutable()
1344 elif isinstance(graph_data, (list, tuple)):
1345 # edge list
1346 return from_edge_list(graph_data, readonly)
1347 elif isinstance(graph_data, scipy.sparse.spmatrix):
1348 # scipy format
1349 return from_scipy_sparse_matrix(graph_data, readonly)
1350 else:
1351 # networkx - any format
1352 try:
1353 gidx = from_networkx(graph_data, readonly)
1354 except Exception: # pylint: disable=broad-except
1355 raise DGLError(
1356 'Error while creating graph from input of type "%s".'
1357 % type(graph_data)
1358 )
1359 return gidx
1360
1361
1362def _get_halo_subgraph_inner_node(halo_subg):

Callers 1

Calls 4

from_edge_listFunction · 0.85
from_scipy_sparse_matrixFunction · 0.85
DGLErrorClass · 0.85
from_networkxFunction · 0.70

Tested by 1