"tests/python/vscode:/vscode.git/clone" did not exist on "0bd79a2bd9b87c45d0acebf8694ee1391ace3ab8"
dgl.DGLGraph.rst 5.02 KB
Newer Older
Minjie Wang's avatar
Minjie Wang committed
1
2
.. _apigraph:

3
dgl.DGLGraph
Minjie Wang's avatar
Minjie Wang committed
4
5
6
=====================================================

.. currentmodule:: dgl
7
.. class:: DGLGraph
Minjie Wang's avatar
Minjie Wang committed
8

9
10
    Class for storing graph structure and node/edge feature data.

Minjie Wang's avatar
Minjie Wang committed
11
    There are a few ways to create a DGLGraph:
12
13
14
15
16
17
18
19
20

    * To create a homogeneous graph from Tensor data, use :func:`dgl.graph`.
    * To create a heterogeneous graph from Tensor data, use :func:`dgl.heterograph`.
    * To create a graph from other data sources, use ``dgl.*`` create ops. See
      :ref:`api-graph-create-ops`.

    Read the user guide chapter :ref:`guide-graph` for an in-depth explanation about its
    usage.

Minjie Wang's avatar
Minjie Wang committed
21
22
23
Querying metagraph structure
----------------------------

24
25
26
Methods for getting information about the node and edge types. They are typically useful
when the graph is heterogeneous.

Minjie Wang's avatar
Minjie Wang committed
27
28
29
.. autosummary::
    :toctree: ../../generated/

30
31
32
33
34
35
36
    DGLGraph.ntypes
    DGLGraph.etypes
    DGLGraph.srctypes
    DGLGraph.dsttypes
    DGLGraph.canonical_etypes
    DGLGraph.metagraph
    DGLGraph.to_canonical_etype
Minjie Wang's avatar
Minjie Wang committed
37

38
39
.. _apigraph-querying-graph-structure:

Minjie Wang's avatar
Minjie Wang committed
40
41
42
Querying graph structure
------------------------

43
44
45
Methods for getting information about the graph structure such as capacity, connectivity,
neighborhood, etc.

Minjie Wang's avatar
Minjie Wang committed
46
47
48
.. autosummary::
    :toctree: ../../generated/

49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
    DGLGraph.num_nodes
    DGLGraph.number_of_nodes
    DGLGraph.num_edges
    DGLGraph.number_of_edges
    DGLGraph.num_src_nodes
    DGLGraph.number_of_src_nodes
    DGLGraph.num_dst_nodes
    DGLGraph.number_of_dst_nodes
    DGLGraph.is_unibipartite
    DGLGraph.is_multigraph
    DGLGraph.is_homogeneous
    DGLGraph.has_nodes
    DGLGraph.has_edges_between
    DGLGraph.predecessors
    DGLGraph.successors
    DGLGraph.edge_ids
    DGLGraph.find_edges
    DGLGraph.in_edges
    DGLGraph.out_edges
    DGLGraph.in_degrees
    DGLGraph.out_degrees
Minjie Wang's avatar
Minjie Wang committed
70
71
72
73

Querying and manipulating sparse format
---------------------------------------

74
75
Methods for getting or manipulating the internal storage formats of a ``DGLGraph``.

Minjie Wang's avatar
Minjie Wang committed
76
77
78
.. autosummary::
    :toctree: ../../generated/

79
    DGLGraph.formats
80
    DGLGraph.create_formats_
Minjie Wang's avatar
Minjie Wang committed
81

82
Querying and manipulating node/edge ID type
Minjie Wang's avatar
Minjie Wang committed
83
84
-----------------------------------------

85
86
87
Methods for getting or manipulating the data type for storing structure-related
data such as node and edge IDs.

Minjie Wang's avatar
Minjie Wang committed
88
89
90
.. autosummary::
    :toctree: ../../generated/

91
92
93
    DGLGraph.idtype
    DGLGraph.long
    DGLGraph.int
Minjie Wang's avatar
Minjie Wang committed
94
95
96
97

Using Node/edge features
------------------------

98
99
100
Methods for getting or setting the data type for storing structure-related
data such as node and edge IDs.

Minjie Wang's avatar
Minjie Wang committed
101
102
103
.. autosummary::
    :toctree: ../../generated/

104
105
106
107
108
109
110
111
112
113
    DGLGraph.nodes
    DGLGraph.ndata
    DGLGraph.edges
    DGLGraph.edata
    DGLGraph.node_attr_schemes
    DGLGraph.edge_attr_schemes
    DGLGraph.srcnodes
    DGLGraph.dstnodes
    DGLGraph.srcdata
    DGLGraph.dstdata
Minjie Wang's avatar
Minjie Wang committed
114

115
116
Transforming graph
------------------
117

118
119
120
121
Methods for generating a new graph by transforming the current ones. Most of them
are alias of the :ref:`api-subgraph-extraction` and :ref:`api-transform`
under the ``dgl`` namespace.

122
123
124
.. autosummary::
    :toctree: ../../generated/

125
126
127
128
129
    DGLGraph.subgraph
    DGLGraph.edge_subgraph
    DGLGraph.node_type_subgraph
    DGLGraph.edge_type_subgraph
    DGLGraph.__getitem__
130
131
132
133
134
    DGLGraph.line_graph
    DGLGraph.reverse
    DGLGraph.add_self_loop
    DGLGraph.remove_self_loop
    DGLGraph.to_simple
135
    DGLGraph.reorder
136
137
138

Adjacency and incidence matrix
---------------------------------
139

140
Methods for getting the adjacency and the incidence matrix of the graph.
Minjie Wang's avatar
Minjie Wang committed
141
142
143
144

.. autosummary::
    :toctree: ../../generated/

145
146
147
148
    DGLGraph.adj
    DGLGraph.adjacency_matrix
    DGLGraph.inc
    DGLGraph.incidence_matrix
Minjie Wang's avatar
Minjie Wang committed
149

150
Computing with DGLGraph
Minjie Wang's avatar
Minjie Wang committed
151
152
-----------------------------

153
154
Methods for performing message passing, applying functions on node/edge features, etc.

Minjie Wang's avatar
Minjie Wang committed
155
156
157
.. autosummary::
    :toctree: ../../generated/

158
159
160
161
162
163
164
165
166
167
168
169
    DGLGraph.apply_nodes
    DGLGraph.apply_edges
    DGLGraph.send_and_recv
    DGLGraph.pull
    DGLGraph.push
    DGLGraph.update_all
    DGLGraph.multi_update_all
    DGLGraph.prop_nodes
    DGLGraph.prop_edges
    DGLGraph.filter_nodes
    DGLGraph.filter_edges

170
171
Querying and manipulating batch information
----------------------------------------------
172

173
Methods for getting/setting the batching information if the current graph is a batched
174
175
graph generated from :func:`dgl.batch`. They are also widely used in the
:ref:`api-batch`.
176
177
178
179
180
181
182

.. autosummary::
    :toctree: ../../generated/

    DGLGraph.batch_size
    DGLGraph.batch_num_nodes
    DGLGraph.batch_num_edges
183
184
185
    DGLGraph.set_batch_num_nodes
    DGLGraph.set_batch_num_edges

186
187
188
189

Mutating topology
-----------------

190
191
Methods for mutating the graph structure *in-place*.

192
193
194
195
196
197
198
199
200
201
202
.. autosummary::
    :toctree: ../../generated/

    DGLGraph.add_nodes
    DGLGraph.add_edges
    DGLGraph.remove_nodes
    DGLGraph.remove_edges

Device Control
--------------

203
204
Methods for getting or changing the device on which the graph is hosted.

205
206
207
208
209
.. autosummary::
    :toctree: ../../generated/

    DGLGraph.to
    DGLGraph.device
210
211
212
213
214
215
216
217
218
219

Misc
----

Other utility methods.

.. autosummary::
    :toctree: ../../generated/

    DGLGraph.local_scope