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

Function from_coo

python/dgl/graph_index.py:1062–1091  ·  view source on GitHub ↗

Convert from coo arrays. Parameters ---------- num_nodes : int Number of nodes. src : Tensor Src end nodes of the edges. dst : Tensor Dst end nodes of the edges. readonly : bool True if the returned graph is readonly. Returns -------

(num_nodes, src, dst, readonly)

Source from the content-addressed store, hash-verified

1060# Conversion functions
1061###############################################################
1062def from_coo(num_nodes, src, dst, readonly):
1063 """Convert from coo arrays.
1064
1065 Parameters
1066 ----------
1067 num_nodes : int
1068 Number of nodes.
1069 src : Tensor
1070 Src end nodes of the edges.
1071 dst : Tensor
1072 Dst end nodes of the edges.
1073 readonly : bool
1074 True if the returned graph is readonly.
1075
1076 Returns
1077 -------
1078 GraphIndex
1079 The graph index.
1080 """
1081 src = utils.toindex(src)
1082 dst = utils.toindex(dst)
1083 if readonly:
1084 gidx = _CAPI_DGLGraphCreate(
1085 src.todgltensor(), dst.todgltensor(), int(num_nodes), readonly
1086 )
1087 else:
1088 gidx = _CAPI_DGLGraphCreateMutable()
1089 gidx.add_nodes(num_nodes)
1090 gidx.add_edges(src, dst)
1091 return gidx
1092
1093
1094def from_csr(indptr, indices, direction):

Callers 4

from_networkxFunction · 0.70
from_scipy_sparse_matrixFunction · 0.70
from_edge_listFunction · 0.70
create_metagraph_indexFunction · 0.70

Calls 3

todgltensorMethod · 0.80
add_nodesMethod · 0.45
add_edgesMethod · 0.45

Tested by

no test coverage detected