dgl.DGLGraph.rst 4.85 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
40

Querying graph structure
------------------------

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

Minjie Wang's avatar
Minjie Wang committed
44
45
46
.. autosummary::
    :toctree: ../../generated/

47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
    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
68
69
70
71

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

72
73
Methods for getting or manipulating the internal storage formats of a ``DGLGraph``.

Minjie Wang's avatar
Minjie Wang committed
74
75
76
.. autosummary::
    :toctree: ../../generated/

77
    DGLGraph.formats
78
    DGLGraph.create_formats_
Minjie Wang's avatar
Minjie Wang committed
79

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

83
84
85
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
86
87
88
.. autosummary::
    :toctree: ../../generated/

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

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

96
97
98
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
99
100
101
.. autosummary::
    :toctree: ../../generated/

102
103
104
105
106
107
108
109
110
111
    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
112

113
114
Transforming graph
------------------
115

116
117
118
119
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.

120
121
122
.. autosummary::
    :toctree: ../../generated/

123
124
125
126
127
    DGLGraph.subgraph
    DGLGraph.edge_subgraph
    DGLGraph.node_type_subgraph
    DGLGraph.edge_type_subgraph
    DGLGraph.__getitem__
128
129
130
131
132
133
134
135
    DGLGraph.line_graph
    DGLGraph.reverse
    DGLGraph.add_self_loop
    DGLGraph.remove_self_loop
    DGLGraph.to_simple

Adjacency and incidence matrix
---------------------------------
136

137
Methods for getting the adjacency and the incidence matrix of the graph.
Minjie Wang's avatar
Minjie Wang committed
138
139
140
141

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

142
143
144
145
    DGLGraph.adj
    DGLGraph.adjacency_matrix
    DGLGraph.inc
    DGLGraph.incidence_matrix
Minjie Wang's avatar
Minjie Wang committed
146

147
Computing with DGLGraph
Minjie Wang's avatar
Minjie Wang committed
148
149
-----------------------------

150
151
Methods for performing message passing, applying functions on node/edge features, etc.

Minjie Wang's avatar
Minjie Wang committed
152
153
154
.. autosummary::
    :toctree: ../../generated/

155
156
157
158
159
160
161
162
163
164
165
166
167
    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

Querying batch summary
168
169
170
171
172
---------------------------------

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

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

    DGLGraph.batch_size
    DGLGraph.batch_num_nodes
    DGLGraph.batch_num_edges

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

184
185
Methods for mutating the graph structure *in-place*.

186
187
188
189
190
191
192
193
194
195
196
.. autosummary::
    :toctree: ../../generated/

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

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

197
198
Methods for getting or changing the device on which the graph is hosted.

199
200
201
202
203
.. autosummary::
    :toctree: ../../generated/

    DGLGraph.to
    DGLGraph.device
204
205
206
207
208
209
210
211
212
213

Misc
----

Other utility methods.

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

    DGLGraph.local_scope