Skip to content

Commit 8dcf7ec

Browse files
committed
animations for iterative layouts
1 parent 97d95d9 commit 8dcf7ec

File tree

1 file changed

+37
-4
lines changed

1 file changed

+37
-4
lines changed

docs/src/index.md

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ CairoMakie.activate!(type="png") # hide
1313
set_theme!(resolution=(800, 400)) #hide
1414
CairoMakie.inline!(true) # hide
1515
using NetworkLayout
16-
using GraphMakie, LightGraphs, LightGraphs
16+
using GraphMakie, LightGraphs
1717
import Random; Random.seed!(2) # hide
1818
nothing #hide
1919
```
2020

2121
# Basic Usage & Algorithms
22-
All of the algorithms follow the [layout interface](@ref). Each layout algorithm
22+
All of the algorithms follow the [Layout Interface](@ref). Each layout algorithm
2323
is represented by a type `Algorithm <: AbstractLayout`. The parameters of each
2424
algorithm can be set with keyword arguments. The `Algorithm` object itself is
2525
callable and transforms the adjacency matrix and returns a list of `Point{N,T}` from [`GeometryBasics.jl`](https://github.com/JuliaGeometry/GeometryBasics.jl).
@@ -39,9 +39,20 @@ using NetworkLayout: SFDP
3939
g = wheel_graph(10)
4040
layout = SFDP(tol=0.01, C=0.2, K=1)
4141
f, ax, p = graphplot(g, layout=layout)
42-
hidedecorations!(ax); hidespines!(ax); ax.aspect = DataAspect(); f #hide
42+
hidedecorations!(ax); hidespines!(ax); ax.aspect = DataAspect(); f
4343
```
4444

45+
### Iterator Example
46+
```@example layouts
47+
iterator = LayoutIterator(layout, adjacency_matrix(g))
48+
record(f, "sfdp_animation.mp4", iterator; framerate = 10) do pos
49+
p[:node_positions][] = pos
50+
autolimits!(ax)
51+
end
52+
nothing #hide
53+
```
54+
![sfdp animation](sfdp_animation.mp4)
55+
4556
## Buchheim Tree Drawing
4657
```@docs
4758
Buchheim
@@ -51,7 +62,6 @@ Buchheim
5162
using NetworkLayout: Buchheim
5263
5364
adj_matrix = [0 1 1 0 0 0 0 0 0 0;
54-
5565
0 0 0 0 1 1 0 0 0 0;
5666
0 0 0 1 0 0 1 0 1 0;
5767
0 0 0 0 0 0 0 0 0 0;
@@ -79,6 +89,16 @@ layout = Spring()
7989
f, ax, p = graphplot(g, layout=layout)
8090
hidedecorations!(ax); hidespines!(ax); ax.aspect = DataAspect(); f #hide
8191
```
92+
### Iterator Example
93+
```@example layouts
94+
iterator = LayoutIterator(layout, adjacency_matrix(g))
95+
record(f, "spring_animation.mp4", iterator; framerate = 10) do pos
96+
p[:node_positions][] = pos
97+
autolimits!(ax)
98+
end
99+
nothing #hide
100+
```
101+
![spring animation](spring_animation.mp4)
82102

83103
## Stress Majorization
84104
```@docs
@@ -92,8 +112,18 @@ layout = Stress()
92112
Random.seed!(1)
93113
f, ax, p = graphplot(g, layout=layout)
94114
hidedecorations!(ax); hidespines!(ax); ax.aspect = DataAspect(); f #hide
115+
```
95116

117+
### Iterator Example
118+
```@example layouts
119+
iterator = LayoutIterator(layout, adjacency_matrix(g))
120+
record(f, "stress_animation.mp4", iterator; framerate = 100) do pos
121+
p[:node_positions][] = pos
122+
autolimits!(ax)
123+
end
124+
nothing #hide
96125
```
126+
![stress animation](stress_animation.mp4)
97127

98128
## Circular Layout
99129
```@docs
@@ -120,6 +150,9 @@ hidedecorations!(ax); hidespines!(ax); ax.aspect = DataAspect(); f #hide
120150
```
121151

122152
## Spectral
153+
```@docs
154+
Spectral
155+
```
123156
Spectral needs 3d which isn't ready yet on the GraphMakie side.
124157
```
125158
using JSServe

0 commit comments

Comments
 (0)