Skip to content

Commit cb1f0cc

Browse files
docstring
1 parent bde2c6a commit cb1f0cc

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

src/gnngraph.jl

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@ const SPARSE_T = AbstractSparseMatrix # subset of ADJMAT_T
1414
GNNGraph(data; [graph_type, ndata, edata, gdata, num_nodes, graph_indicator, dir])
1515
GNNGraph(g::GNNGraph; [ndata, edata, gdata])
1616
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.
2527
2628
A `GNNGraph` can also represent multiple graphs batched togheter
2729
(see [`Flux.batch`](@ref) or [`SparseArrays.blockdiag`](@ref)).
@@ -64,9 +66,10 @@ using Flux, GraphNeuralNetworks
6466
data = [[2,3], [1,4,5], [1], [2,5], [2,4]]
6567
g = GNNGraph(data)
6668
67-
# Number of nodes and edges
69+
# Number of nodes, edges, and batched graphs
6870
g.num_nodes # 5
6971
g.num_edges # 10
72+
g.num_graphs # 1
7073
7174
# Same graph in COO representation
7275
s = [1,1,2,2,2,3,4,4,5,5]
@@ -76,8 +79,14 @@ g = GNNGraph(s, t)
7679
# From a LightGraphs' graph
7780
g = GNNGraph(erdos_renyi(100, 20))
7881
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
8190
8291
# Send to gpu
8392
g = g |> gpu

0 commit comments

Comments
 (0)