Skip to content

Commit 18f26fa

Browse files
docs improvements (#539)
1 parent a6e6bd8 commit 18f26fa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+721
-736
lines changed

.github/workflows/multidocs.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,6 @@ jobs:
6161
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # For authentication with GitHub Actions token
6262
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
6363

64-
# Build tutorials
65-
- name: Install dependencies for tutorials
66-
run: julia --project=tutorials/docs/ -e '
67-
using Pkg;
68-
pkg"dev ./GraphNeuralNetworks ./GNNlib ./GNNGraphs";
69-
Pkg.instantiate();
70-
include("tutorials/docs/make.jl")'
71-
env:
72-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # For authentication with GitHub Actions token
73-
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
7464

7565
# Build and deploy multidocs
7666
- name: Install dependencies for multidocs

GNNGraphs/docs/make.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Documenter
22
using DocumenterInterLinks
33
using GNNGraphs
4+
using MLUtils # this is needed by setdocmeta!
45
import Graphs
56
using Graphs: induced_subgraph
67

GNNGraphs/docs/src/api/gnngraph.md

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
```@meta
22
CurrentModule = GNNGraphs
3+
CollapsedDocStrings = true
34
```
45

56
# GNNGraph
@@ -10,12 +11,6 @@ Besides the methods documented here, one can rely on the large set of functional
1011
given by [Graphs.jl](https://github.com/JuliaGraphs/Graphs.jl) thanks to the fact
1112
that `GNNGraph` inherits from `Graphs.AbstractGraph`.
1213

13-
## Index
14-
15-
```@index
16-
Order = [:type, :function]
17-
Pages = ["gnngraph.md"]
18-
```
1914

2015
## GNNGraph type
2116

@@ -36,7 +31,7 @@ Private = false
3631

3732
```@autodocs
3833
Modules = [GNNGraphs]
39-
Pages = ["query.jl"]
34+
Pages = ["src/query.jl"]
4035
Private = false
4136
```
4237

@@ -48,7 +43,7 @@ Graphs.neighbors(::GNNGraph, ::Integer)
4843

4944
```@autodocs
5045
Modules = [GNNGraphs]
51-
Pages = ["transform.jl"]
46+
Pages = ["src/transform.jl"]
5247
Private = false
5348
```
5449

@@ -63,17 +58,16 @@ GNNGraphs.color_refinement
6358

6459
```@autodocs
6560
Modules = [GNNGraphs]
66-
Pages = ["generate.jl"]
61+
Pages = ["src/generate.jl"]
6762
Private = false
6863
Filter = t -> typeof(t) <: Function && t!=rand_temporal_radius_graph && t!=rand_temporal_hyperbolic_graph
69-
7064
```
7165

7266
## Operators
7367

7468
```@autodocs
7569
Modules = [GNNGraphs]
76-
Pages = ["operators.jl"]
70+
Pages = ["src/operators.jl"]
7771
Private = false
7872
```
7973

@@ -85,7 +79,7 @@ Base.intersect
8579

8680
```@autodocs
8781
Modules = [GNNGraphs]
88-
Pages = ["sampling.jl"]
82+
Pages = ["src/sampling.jl"]
8983
Private = false
9084
```
9185

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,40 @@
1+
```@meta
2+
CurrentModule = GNNGraphs
3+
CollapsedDocStrings = true
4+
```
5+
16
# Heterogeneous Graphs
27

38

49
## GNNHeteroGraph
510
Documentation page for the type `GNNHeteroGraph` representing heterogeneous graphs, where nodes and edges can have different types.
611

7-
812
```@autodocs
913
Modules = [GNNGraphs]
1014
Pages = ["gnnheterograph.jl"]
1115
Private = false
1216
```
1317

14-
```@docs
15-
Graphs.has_edge(::GNNHeteroGraph, ::Tuple{Symbol, Symbol, Symbol}, ::Integer, ::Integer)
18+
## Query
19+
20+
```@autodocs
21+
Modules = [GNNGraphs]
22+
Pages = ["gnnheterograph/query.jl"]
23+
Private = false
24+
```
25+
26+
## Transform
27+
28+
```@autodocs
29+
Modules = [GNNGraphs]
30+
Pages = ["gnnheterograph/transform.jl"]
31+
Private = false
1632
```
1733

34+
## Generate
35+
36+
```@autodocs
37+
Modules = [GNNGraphs]
38+
Pages = ["gnnheterograph/generate.jl"]
39+
Private = false
40+
```

GNNGraphs/docs/src/api/samplers.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
```@meta
22
CurrentModule = GNNGraphs
3+
CollapsedDocStrings = true
34
```
45

56
# Samplers
67

7-
8-
## Docs
9-
108
```@autodocs
119
Modules = [GNNGraphs]
1210
Pages = ["samplers.jl"]

GNNGraphs/docs/src/api/temporalgraph.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
```@meta
2+
CurrentModule = GNNGraphs
3+
CollapsedDocStrings = true
4+
```
5+
16
# Temporal Graphs
27

38
## TemporalSnapshotsGNNGraph
@@ -10,7 +15,7 @@ Pages = ["temporalsnapshotsgnngraph.jl"]
1015
Private = false
1116
```
1217

13-
## TemporalSnapshotsGNNGraph random generators
18+
## Random Generators
1419

1520
```@docs
1621
rand_temporal_radius_graph

GNNGraphs/docs/src/guides/heterograph.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
```@meta
2+
CurrentModule = GNNGraphs
3+
```
4+
15
# Heterogeneous Graphs
26

37
Heterogeneous graphs (also called heterographs), are graphs where each node has a type,
@@ -67,18 +71,15 @@ julia> g.num_edges
6771
Dict{Tuple{Symbol, Symbol, Symbol}, Int64} with 1 entry:
6872
(:user, :rate, :movie) => 4
6973
70-
# source and target node for a given relation
71-
julia> edge_index(g, (:user, :rate, :movie))
74+
julia> edge_index(g, (:user, :rate, :movie)) # source and target node for a given relation
7275
([1, 1, 2, 3], [7, 13, 5, 7])
7376
74-
# node types
75-
julia> g.ntypes
77+
julia> g.ntypes # node types
7678
2-element Vector{Symbol}:
7779
:user
7880
:movie
7981
80-
# edge types
81-
julia> g.etypes
82+
julia> g.etypes # edge types
8283
1-element Vector{Tuple{Symbol, Symbol, Symbol}}:
8384
(:user, :rate, :movie)
8485
```
@@ -120,8 +121,8 @@ GNNHeteroGraph:
120121
Batching is automatically performed by the [`DataLoader`](https://fluxml.ai/Flux.jl/stable/data/mlutils/#MLUtils.DataLoader) iterator
121122
when the `collate` option is set to `true`.
122123

123-
```jldoctest hetero
124-
using Flux: DataLoader
124+
```julia
125+
using MLUtils: DataLoader
125126

126127
data = [rand_bipartite_heterograph((5, 10), 20,
127128
ndata=Dict(:A=>rand(Float32, 3, 5)))

GNNGraphs/docs/src/guides/temporalgraph.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
```@meta
2+
CurrentModule = GNNGraphs
3+
```
4+
15
# Temporal Graphs
26

37
Temporal Graphs are graphs with time varying topologies and features. In GNNGraphs.jl, temporal graphs with fixed number of nodes over time are supported by the [`TemporalSnapshotsGNNGraph`](@ref) type.
@@ -45,7 +49,7 @@ TemporalSnapshotsGNNGraph:
4549

4650
See [`rand_temporal_radius_graph`](@ref) and [`rand_temporal_hyperbolic_graph`](@ref) for generating random temporal graphs.
4751

48-
```jldoctest temporal
52+
```julia
4953
julia> tg = rand_temporal_radius_graph(10, 3, 0.1, 0.5)
5054
TemporalSnapshotsGNNGraph:
5155
num_nodes: [10, 10, 10]
@@ -97,28 +101,30 @@ A temporal graph can store global feature for the entire time series in the `tgd
97101
Also, each snapshot can store node, edge, and graph features in the `ndata`, `edata`, and `gdata` fields, respectively.
98102

99103
```jldoctest temporal
100-
julia> snapshots = [rand_graph(10,20; ndata = rand(3,10)), rand_graph(10,14; ndata = rand(4,10)), rand_graph(10,22; ndata = rand(5,10))]; # node features at construction time
104+
julia> snapshots = [rand_graph(10, 20; ndata = rand(Float32, 3, 10)),
105+
rand_graph(10, 14; ndata = rand(Float32, 4, 10)),
106+
rand_graph(10, 22; ndata = rand(Float32, 5, 10))]; # node features at construction time
101107
102108
julia> tg = TemporalSnapshotsGNNGraph(snapshots);
103109
104-
julia> tg.tgdata.y = rand(3,1); # add global features after construction
110+
julia> tg.tgdata.y = rand(Float32, 3, 1); # add global features after construction
105111
106112
julia> tg
107113
TemporalSnapshotsGNNGraph:
108114
num_nodes: [10, 10, 10]
109115
num_edges: [20, 14, 22]
110116
num_snapshots: 3
111117
tgdata:
112-
y = 3×1 Matrix{Float64}
118+
y = 3×1 Matrix{Float32}
113119
114120
julia> tg.ndata # vector of DataStore containing node features for each snapshot
115121
3-element Vector{DataStore}:
116122
DataStore(10) with 1 element:
117-
x = 3×10 Matrix{Float64}
123+
x = 3×10 Matrix{Float32}
118124
DataStore(10) with 1 element:
119-
x = 4×10 Matrix{Float64}
125+
x = 4×10 Matrix{Float32}
120126
DataStore(10) with 1 element:
121-
x = 5×10 Matrix{Float64}
127+
x = 5×10 Matrix{Float32}
122128
123129
julia> [ds.x for ds in tg.ndata]; # vector containing the x feature of each snapshot
124130

GNNGraphs/src/GNNGraphs.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ using SparseArrays
44
using Functors: @functor
55
import Graphs
66
using Graphs: AbstractGraph, outneighbors, inneighbors, adjacency_matrix, degree,
7-
has_self_loops, is_directed, induced_subgraph
7+
has_self_loops, is_directed, induced_subgraph, has_edge
88
import NearestNeighbors
99
import NNlib
1010
import StatsBase
@@ -30,7 +30,7 @@ export GNNGraph,
3030
edge_features,
3131
graph_features
3232

33-
include("gnnheterograph.jl")
33+
include("gnnheterograph/gnnheterograph.jl")
3434
export GNNHeteroGraph,
3535
num_edge_types,
3636
num_node_types,
@@ -44,6 +44,7 @@ export TemporalSnapshotsGNNGraph,
4444
# remove_snapshot!
4545

4646
include("query.jl")
47+
include("gnnheterograph/query.jl")
4748
export adjacency_list,
4849
edge_index,
4950
get_edge_weight,
@@ -58,13 +59,15 @@ export adjacency_list,
5859
# from Graphs
5960
adjacency_matrix,
6061
degree,
61-
has_self_loops,
62+
has_edge,
6263
has_isolated_nodes,
64+
has_self_loops,
6365
inneighbors,
6466
outneighbors,
6567
khop_adj
6668

6769
include("transform.jl")
70+
include("gnnheterograph/transform.jl")
6871
export add_nodes,
6972
add_edges,
7073
add_self_loops,
@@ -88,6 +91,7 @@ export add_nodes,
8891
blockdiag
8992

9093
include("generate.jl")
94+
include("gnnheterograph/generate.jl")
9195
export rand_graph,
9296
rand_heterograph,
9397
rand_bipartite_heterograph,
@@ -104,6 +108,7 @@ include("operators.jl")
104108

105109
include("convert.jl")
106110
include("utils.jl")
111+
include("gnnheterograph/utils.jl")
107112
export sort_edge_index, color_refinement
108113

109114
include("gatherscatter.jl")

GNNGraphs/src/datastore.jl

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,12 @@ DataStore(3) with 2 elements:
1515
x = 2×3 Matrix{Float32}
1616
1717
julia> ds = DataStore(3, Dict(:x => rand(Float32, 2, 3), :y => rand(Float32, 3))); # equivalent to above
18-
19-
julia> ds = DataStore(3, (x = rand(Float32, 2, 3), y = rand(Float32, 30)))
20-
ERROR: AssertionError: DataStore: data[y] has 30 observations, but n = 3
21-
Stacktrace:
22-
[1] DataStore(n::Int64, data::Dict{Symbol, Any})
23-
@ GNNGraphs ~/.julia/dev/GNNGraphs/datastore.jl:54
24-
[2] DataStore(n::Int64, data::NamedTuple{(:x, :y), Tuple{Matrix{Float32}, Vector{Float32}}})
25-
@ GNNGraphs ~/.julia/dev/GNNGraphs/datastore.jl:73
26-
[3] top-level scope
27-
@ REPL[13]:1
28-
29-
julia> ds = DataStore(x = randFloat32, 2, 3), y = rand(Float32, 30)) # no checks
30-
DataStore() with 2 elements:
31-
y = 30-element Vector{Float32}
32-
x = 2×3 Matrix{Float32}
33-
y = 30-element Vector{Float64}
34-
x = 2×3 Matrix{Float64}
3518
```
3619
3720
The `DataStore` has an interface similar to both dictionaries and named tuples.
3821
Arrays can be accessed and added using either the indexing or the property syntax:
3922
40-
```jldoctest datastore
23+
```jldoctest docstr_datastore
4124
julia> ds = DataStore(x = ones(Float32, 2, 3), y = zeros(Float32, 3))
4225
DataStore() with 2 elements:
4326
y = 3-element Vector{Float32}
@@ -59,14 +42,16 @@ The `DataStore` can be iterated over, and the keys and values can be accessed
5942
using `keys(ds)` and `values(ds)`. `map(f, ds)` applies the function `f`
6043
to each feature array:
6144
62-
```jldoctest datastore
45+
```jldoctest docstr_datastore
6346
julia> ds2 = map(x -> x .+ 1, ds)
64-
DataStore() with 2 elements:
65-
a = 2-element Vector{Float64}
66-
b = 2-element Vector{Float64}
47+
DataStore() with 3 elements:
48+
y = 3-element Vector{Float32}
49+
z = 3-element Vector{Float32}
50+
x = 2×3 Matrix{Float32}
6751
68-
julia> ds2.a
69-
2-element Vector{Float64}:
52+
julia> ds2.z
53+
3-element Vector{Float32}:
54+
1.0
7055
1.0
7156
1.0
7257
```

0 commit comments

Comments
 (0)