@@ -14,14 +14,16 @@ const SPARSE_T = AbstractSparseMatrix # subset of ADJMAT_T
14
14
GNNGraph(data; [graph_type, ndata, edata, gdata, num_nodes, graph_indicator, dir])
15
15
GNNGraph(g::GNNGraph; [ndata, edata, gdata])
16
16
17
- A type representing a graph structure and storing also arrays
18
- that contain features associated to nodes, edges, and the whole graph.
19
-
20
- A `GNNGraph` can be constructed out of different objects `data` representing
21
- the connections inside the graph, while the internal representation type
22
- is governed by `graph_type`.
23
- When constructed from another graph `g`, the internal graph representation
24
- is preserved and shared.
17
+ A type representing a graph structure and storing also
18
+ feature arrays associated to nodes, edges, and to the whole graph (global features).
19
+
20
+ A `GNNGraph` can be constructed out of different objects `data` expressing
21
+ the connections inside the graph. The internal representation type
22
+ is determined by `graph_type`.
23
+
24
+ When constructed from another `GNNGraph`, the internal graph representation
25
+ is preserved and shared. The node/edge/global features are transmitted
26
+ as well, unless explicitely changed though keyword arguments.
25
27
26
28
A `GNNGraph` can also represent multiple graphs batched togheter
27
29
(see [`Flux.batch`](@ref) or [`SparseArrays.blockdiag`](@ref)).
@@ -64,9 +66,10 @@ using Flux, GraphNeuralNetworks
64
66
data = [[2,3], [1,4,5], [1], [2,5], [2,4]]
65
67
g = GNNGraph(data)
66
68
67
- # Number of nodes and edges
69
+ # Number of nodes, edges, and batched graphs
68
70
g.num_nodes # 5
69
71
g.num_edges # 10
72
+ g.num_graphs # 1
70
73
71
74
# Same graph in COO representation
72
75
s = [1,1,2,2,2,3,4,4,5,5]
@@ -76,8 +79,14 @@ g = GNNGraph(s, t)
76
79
# From a LightGraphs' graph
77
80
g = GNNGraph(erdos_renyi(100, 20))
78
81
79
- # Copy graph while also adding node features
80
- g = GNNGraph(g, ndata = (x = rand(100, g.num_nodes),))
82
+ # Add node 2 node feature arrays
83
+ g = GNNGraph(g, ndata = (X = rand(100, g.num_nodes), y = rand(g.num_nodes)))
84
+
85
+ # Add node features and edge features with default names `X` and `E`
86
+ g = GNNGraph(g, ndata = rand(100, g.num_nodes), edata = rand(16, g.num_nodes))
87
+
88
+ g.ndata.X
89
+ g.ndata.E
81
90
82
91
# Send to gpu
83
92
g = g |> gpu
0 commit comments