@@ -11,28 +11,34 @@ const ADJMAT_T = AbstractMatrix
11
11
const SPARSE_T = AbstractSparseMatrix # subset of ADJMAT_T
12
12
const CUMAT_T = Union{AnyCuMatrix, CUDA. CUSPARSE. CuSparseMatrix}
13
13
14
- """
14
+ """
15
15
GNNGraph(data; [graph_type, ndata, edata, gdata, num_nodes, graph_indicator, dir])
16
16
GNNGraph(g::GNNGraph; [ndata, edata, gdata])
17
17
18
- A type representing a graph structure and storing also
19
- feature arrays associated to nodes, edges, and to the whole graph (global features) .
18
+ A type representing a graph structure that also stores
19
+ feature arrays associated to nodes, edges, and the graph itself .
20
20
21
- A `GNNGraph` can be constructed out of different objects `data` expressing
22
- the connections inside the graph. The internal representation type
21
+ A `GNNGraph` can be constructed out of different `data` objects
22
+ expressing the connections inside the graph. The internal representation type
23
23
is determined by `graph_type`.
24
24
25
25
When constructed from another `GNNGraph`, the internal graph representation
26
- is preserved and shared. The node/edge/global features are transmitted
27
- as well, unless explicitely changed though keyword arguments.
26
+ is preserved and shared. The node/edge/graph features are retained
27
+ as well, unless explicitely set by the keyword arguments
28
+ `ndata`, `edata`, and `gdata`.
28
29
29
30
A `GNNGraph` can also represent multiple graphs batched togheter
30
31
(see [`Flux.batch`](@ref) or [`SparseArrays.blockdiag`](@ref)).
31
32
The field `g.graph_indicator` contains the graph membership
32
33
of each node.
33
34
34
- A `GNNGraph` is a Graphs' `AbstractGraph`, therefore any functionality
35
- from the Graphs' graph library can be used on it.
35
+ `GNNGraph`s are always directed graphs, therefore each edge is defined
36
+ by a source node and a target node (see [`edge_index`](@ref)).
37
+ Self loops (edges connecting a node to itself) and multiple edges
38
+ (more than one edge between the same pair of nodes) are supported.
39
+
40
+ A `GNNGraph` is a Graphs.jl's `AbstractGraph`, therefore it supports most
41
+ functionality from that library.
36
42
37
43
# Arguments
38
44
@@ -54,9 +60,9 @@ from the Graphs' graph library can be used on it.
54
60
Possible values are `:out` and `:in`. Default `:out`.
55
61
- `num_nodes`: The number of nodes. If not specified, inferred from `g`. Default `nothing`.
56
62
- `graph_indicator`: For batched graphs, a vector containing the graph assigment of each node. Default `nothing`.
57
- - `ndata`: Node features. A named tuple of arrays whose last dimension has size num_nodes.
58
- - `edata`: Edge features. A named tuple of arrays whose whose last dimension has size num_edges.
59
- - `gdata`: Global features. A named tuple of arrays whose has size num_graphs.
63
+ - `ndata`: Node features. A named tuple of arrays whose last dimension has size ` num_nodes` .
64
+ - `edata`: Edge features. A named tuple of arrays whose last dimension has size ` num_edges` .
65
+ - `gdata`: Graph features. A named tuple of arrays whose last dimension has size ` num_graphs` .
60
66
61
67
# Usage.
62
68
@@ -97,7 +103,7 @@ g = g |> gpu
97
103
source, target = edge_index(g)
98
104
```
99
105
"""
100
- struct GNNGraph{T<: Union{COO_T,ADJMAT_T} }
106
+ struct GNNGraph{T<: Union{COO_T,ADJMAT_T} } <: AbstractGraph{Int}
101
107
graph:: T
102
108
num_nodes:: Int
103
109
num_edges:: Int
0 commit comments