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

Method __init__

python/dgl/heterograph.py:57–124  ·  view source on GitHub ↗

Internal constructor for creating a DGLGraph. Parameters ---------- gidx : HeteroGraphIndex Graph index object. ntypes : list of str, pair of list of str Node type list. ``ntypes[i]`` stores the name of node type i. If a pair is gi

(
        self,
        gidx=[],
        ntypes=["_N"],
        etypes=["_E"],
        node_frames=None,
        edge_frames=None,
        **deprecate_kwargs
    )

Source from the content-addressed store, hash-verified

55
56 # pylint: disable=unused-argument, dangerous-default-value
57 def __init__(
58 self,
59 gidx=[],
60 ntypes=["_N"],
61 etypes=["_E"],
62 node_frames=None,
63 edge_frames=None,
64 **deprecate_kwargs
65 ):
66 """Internal constructor for creating a DGLGraph.
67
68 Parameters
69 ----------
70 gidx : HeteroGraphIndex
71 Graph index object.
72 ntypes : list of str, pair of list of str
73 Node type list. ``ntypes[i]`` stores the name of node type i.
74 If a pair is given, the graph created is a uni-directional bipartite graph,
75 and its SRC node types and DST node types are given as in the pair.
76 etypes : list of str
77 Edge type list. ``etypes[i]`` stores the name of edge type i.
78 node_frames : list[Frame], optional
79 Node feature storage. If None, empty frame is created.
80 Otherwise, ``node_frames[i]`` stores the node features
81 of node type i. (default: None)
82 edge_frames : list[Frame], optional
83 Edge feature storage. If None, empty frame is created.
84 Otherwise, ``edge_frames[i]`` stores the edge features
85 of edge type i. (default: None)
86 """
87 if isinstance(gidx, DGLGraph):
88 raise DGLError(
89 "The input is already a DGLGraph. No need to create it again."
90 )
91 if not isinstance(gidx, heterograph_index.HeteroGraphIndex):
92 dgl_warning(
93 "Recommend creating graphs by `dgl.graph(data)`"
94 " instead of `dgl.DGLGraph(data)`."
95 )
96 (sparse_fmt, arrays), num_src, num_dst = utils.graphdata2tensors(
97 gidx
98 )
99 if sparse_fmt == "coo":
100 gidx = heterograph_index.create_unitgraph_from_coo(
101 1,
102 num_src,
103 num_dst,
104 arrays[0],
105 arrays[1],
106 ["coo", "csr", "csc"],
107 )
108 else:
109 gidx = heterograph_index.create_unitgraph_from_csr(
110 1,
111 num_src,
112 num_dst,
113 arrays[0],
114 arrays[1],

Callers

nothing calls this directly

Calls 5

_initMethod · 0.95
DGLErrorClass · 0.85
dgl_warningFunction · 0.85
formatMethod · 0.80
keysMethod · 0.45

Tested by

no test coverage detected