dgl.rst 4.72 KB
Newer Older
Minjie Wang's avatar
Minjie Wang committed
1
2
3
4
5
6
.. _apidgl:

dgl
=============================

.. currentmodule:: dgl
7
8
9
.. automodule:: dgl

.. _api-graph-create-ops:
Minjie Wang's avatar
Minjie Wang committed
10
11
12
13

Graph Create Ops
-------------------------

14
15
Operators for constructing :class:`DGLGraph` from raw data formats.

Minjie Wang's avatar
Minjie Wang committed
16
17
18
19
20
.. autosummary::
    :toctree: ../../generated/

    graph
    heterograph
21
    from_cugraph
Minjie Wang's avatar
Minjie Wang committed
22
23
24
25
26
27
28
29
    from_scipy
    from_networkx
    bipartite_from_scipy
    bipartite_from_networkx
    rand_graph
    rand_bipartite
    knn_graph
    segmented_knn_graph
30
    radius_graph
31
32
    create_block
    block_to_graph
Mufei Li's avatar
Mufei Li committed
33
    merge
Minjie Wang's avatar
Minjie Wang committed
34

35
36
.. _api-subgraph-extraction:

37
Subgraph Extraction Ops
Minjie Wang's avatar
Minjie Wang committed
38
39
-------------------------------------

40
41
Operators for extracting and returning subgraphs.

Minjie Wang's avatar
Minjie Wang committed
42
43
44
45
46
47
48
49
50
.. autosummary::
    :toctree: ../../generated/

    node_subgraph
    edge_subgraph
    node_type_subgraph
    edge_type_subgraph
    in_subgraph
    out_subgraph
51
52
    khop_in_subgraph
    khop_out_subgraph
Minjie Wang's avatar
Minjie Wang committed
53

54
55
56
57
58
59
.. _api-transform:

Graph Transform Ops
----------------------------------

Operators for generating new graphs by manipulating the structure of the existing ones.
Minjie Wang's avatar
Minjie Wang committed
60
61
62
63
64

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

    add_edges
65
66
    add_nodes
    add_reverse_edges
Minjie Wang's avatar
Minjie Wang committed
67
    add_self_loop
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
    adj_product_graph
    adj_sum_graph
    compact_graphs
    khop_adj
    khop_graph
    knn_graph
    laplacian_lambda_max
    line_graph
    metapath_reachable_graph
    metis_partition
    metis_partition_assignment
    norm_by_dst
    partition_graph_with_halo
    radius_graph
    remove_edges
    remove_nodes
Minjie Wang's avatar
Minjie Wang committed
84
    remove_self_loop
85
    reorder_graph
Minjie Wang's avatar
Minjie Wang committed
86
    reverse
87
88
89
    segmented_knn_graph
    sort_csr_by_tag
    sort_csc_by_tag
Minjie Wang's avatar
Minjie Wang committed
90
    to_bidirected
91
    to_bidirected_stale
Minjie Wang's avatar
Minjie Wang committed
92
    to_block
93
    to_cugraph
94
95
96
    to_double
    to_float
    to_half
97
98
    to_heterogeneous
    to_homogeneous
Minjie Wang's avatar
Minjie Wang committed
99
    to_networkx
100
101
    to_simple
    to_simple_graph
Minjie Wang's avatar
Minjie Wang committed
102

103
104
105
106
107
108
109
110
111
112
113
.. _api-positional-encoding:

Graph Positional Encoding Ops:
-----------------------------------------

Operators for generating positional encodings of each node.

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

    random_walk_pe
114
    lap_pe
115
    double_radius_node_labeling
116
    shortest_dist
117
    svd_pe
118

119
120
121
122
123
124
125
126
127
128
129
.. _api-partition:

Graph Partition Utilities
-------------------------
.. autosummary::
    :toctree: ../../generated/

    metis_partition
    metis_partition_assignment
    partition_graph_with_halo

130
131
132
.. _api-batch:

Batching and Reading Out Ops
Minjie Wang's avatar
Minjie Wang committed
133
134
-------------------------------

135
136
137
Operators for batching multiple graphs into one for batch processing and
operators for computing graph-level representation for both single and batched graphs.

Minjie Wang's avatar
Minjie Wang committed
138
139
140
141
142
.. autosummary::
    :toctree: ../../generated/

    batch
    unbatch
143
    slice_batch
Minjie Wang's avatar
Minjie Wang committed
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
    readout_nodes
    readout_edges
    sum_nodes
    sum_edges
    mean_nodes
    mean_edges
    max_nodes
    max_edges
    softmax_nodes
    softmax_edges
    broadcast_nodes
    broadcast_edges
    topk_nodes
    topk_edges

159
Adjacency Related Utilities
Minjie Wang's avatar
Minjie Wang committed
160
161
-------------------------------

162
163
Utilities for computing adjacency matrix and Lapacian matrix.

Minjie Wang's avatar
Minjie Wang committed
164
165
166
167
168
169
.. autosummary::
    :toctree: ../../generated/

    khop_adj
    laplacian_lambda_max

170
Graph Traversal & Message Propagation
Minjie Wang's avatar
Minjie Wang committed
171
172
------------------------------------------

173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
DGL implements graph traversal algorithms implemented as python generators,
which returns the visited set of nodes or edges (in ID tensor) at each iteration.
The naming convention is ``<algorithm>_[nodes|edges]_generator``.
An example usage is as follows.

.. code:: python

    g = ...  # some DGLGraph
    for nodes in dgl.bfs_nodes_generator(g, 0):
        do_something(nodes)

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

    bfs_nodes_generator
    bfs_edges_generator
    topological_nodes_generator
    dfs_edges_generator
    dfs_labeled_edges_generator

DGL provides APIs to perform message passing following graph traversal order. ``prop_nodes_XXX``
calls traversal algorithm ``XXX`` and triggers :func:`~DGLGraph.pull()` on the visited node
set at each iteration. ``prop_edges_YYY`` applies traversal algorithm ``YYY`` and triggers
:func:`~DGLGraph.send_and_recv()` on the visited edge set at each iteration.
197

Minjie Wang's avatar
Minjie Wang committed
198
199
200
201
202
203
204
205
206
.. autosummary::
    :toctree: ../../generated/

    prop_nodes
    prop_nodes_bfs
    prop_nodes_topo
    prop_edges
    prop_edges_dfs

207
208
209
210
211
212
213
214
Homophily Measures
-------------------------

Utilities for measuring homophily of a graph

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

215
    edge_homophily
216
    node_homophily
217
    linkx_homophily
218

Minjie Wang's avatar
Minjie Wang committed
219
220
Utilities
-----------------------------------------------
221

222
Other utilities for controlling randomness, saving and loading graphs, setting and getting runtime configurations, functions that applies
223
the same function to every elements in a container, etc.
224

Minjie Wang's avatar
Minjie Wang committed
225
226
227
228
.. autosummary::
    :toctree: ../../generated/

    seed
Jinjing Zhou's avatar
Jinjing Zhou committed
229
230
    save_graphs
    load_graphs
231
    apply_each
232
233
    use_libxsmm
    is_libxsmm_enabled