Skip to content

Commit 5f50a32

Browse files
committed
show gallery
1 parent 79df174 commit 5f50a32

File tree

5 files changed

+8
-38
lines changed

5 files changed

+8
-38
lines changed

docs/Project.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
[deps]
2-
Compose = "a81c6b42-2e10-5240-aca2-a61377ecd94b"
32
DocThemeIndigo = "8bac0ac5-51bf-41f9-885e-2bf1ac2bec5f"
43
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
54
GenericTensorNetworks = "3521c873-ad32-4bb4-b63d-f4f178f42b49"

examples/DominatingSet.jl

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# The decision version of finding the minimum dominating set is an NP-complete.
1111
# In the following, we are going to solve the dominating set problem on the Petersen graph.
1212

13-
using GenericTensorNetworks, Graphs, Compose
13+
using GenericTensorNetworks, Graphs
1414

1515
graph = Graphs.smallgraph(:petersen)
1616

@@ -72,13 +72,7 @@ all(c->is_dominating_set(graph, c), min_configs)
7272

7373
#
7474

75-
imgs = ntuple(k->show_graph(graph;
76-
locs=locations, scale=0.25,
77-
vertex_colors=[iszero(min_configs[k][i]) ? "white" : "red"
78-
for i=1:nv(graph)]), length(min_configs));
79-
80-
Compose.set_default_graphic_size(18cm, 8cm); Compose.compose(context(),
81-
ntuple(k->(context((mod1(k,5)-1)/5, ((k-1)÷5)/2, 1.2/5, 1.0/2), imgs[k]), 10)...)
75+
show_gallery(graph, (2, 5); locs=locations, vertex_configs=min_configs)
8276

8377
# Similarly, if one is only interested in computing one of the minimum dominating sets,
8478
# one can use the graph property [`SingleConfigMin`](@ref).

examples/IndependentSet.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ all_max_configs = solve(problem, ConfigsMax(; bounded=true))[]
130130

131131
all_max_configs.c.data
132132

133-
# Let us visualize the solutions with the visualization package [`Compose`](https://github.com/GiovineItalia/Compose.jl).
133+
# These solutions can be visualized with the [`show_gallery`](@ref) function.
134134
show_gallery(graph, (1, length(all_max_configs.c)); locs=locations, vertex_configs=all_max_configs.c);
135135

136136
# We can use [`ConfigsAll`](@ref) to enumerate all sets satisfying the independence constraint.

examples/MaximalIS.jl

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# It is different from maximum independent set because it does not require the set to have the max size.
1010
# In the following, we are going to solve the maximal independent set problem on the Petersen graph.
1111

12-
using GenericTensorNetworks, Graphs, Compose
12+
using GenericTensorNetworks, Graphs
1313

1414
graph = Graphs.smallgraph(:petersen)
1515

@@ -73,13 +73,7 @@ all(c->is_maximal_independent_set(graph, c), maximal_configs)
7373

7474
#
7575

76-
imgs = ntuple(k->show_graph(graph;
77-
locs=locations, scale=0.25,
78-
vertex_colors=[iszero(maximal_configs[k][i]) ? "white" : "red"
79-
for i=1:nv(graph)]), length(maximal_configs));
80-
81-
Compose.set_default_graphic_size(18cm, 12cm); Compose.compose(context(),
82-
ntuple(k->(context((mod1(k,5)-1)/5, ((k-1)÷5)/3, 1.2/5, 1.0/3), imgs[k]), 15)...)
76+
show_gallery(graph, (3, 5); locs=locations, vertex_configs=maximal_configs)
8377

8478
# This result should be consistent with that given by the [Bron Kerbosch algorithm](https://en.wikipedia.org/wiki/Bron%E2%80%93Kerbosch_algorithm) on the complement of Petersen graph.
8579
cliques = maximal_cliques(complement(graph))
@@ -90,13 +84,7 @@ cliques = maximal_cliques(complement(graph))
9084
# It is the [`ConfigsMin`](@ref) property in the program.
9185
minimum_maximal_configs = solve(problem, ConfigsMin())[].c
9286

93-
imgs2 = ntuple(k->show_graph(graph;
94-
locs=locations, scale=0.25,
95-
vertex_colors=[iszero(minimum_maximal_configs[k][i]) ? "white" : "red"
96-
for i=1:nv(graph)]), length(minimum_maximal_configs));
97-
98-
Compose.set_default_graphic_size(15cm, 12cm); Compose.compose(context(),
99-
ntuple(k->(context((mod1(k,4)-1)/4, ((k-1)÷5)/3, 1.2/4, 1.0/3), imgs2[k]), 10)...)
87+
show_gallery(graph, (2, 5); locs=locations, vertex_configs=minimum_maximal_configs)
10088

10189
# Similarly, if one is only interested in computing one of the minimum sets,
10290
# one can use the graph property [`SingleConfigMin`](@ref).

examples/weighted.jl

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,6 @@ max5_configs = solve(problem, SingleConfigMax(5))[]
3333
# The return value also has type [`ExtendedTropical`](@ref), but this time the element type of `orders` has been changed to [`CountingTropical`](@ref)`{Float64,`[`ConfigSampler`](@ref)`}`.
3434
max5_configs.orders
3535

36-
# Let us visually check these graphs
37-
using Compose
38-
39-
imgs_max5 = ntuple(k->show_graph(graph;
40-
locs=locations, scale=0.25,
41-
vertex_colors=[iszero(max5_configs.orders[k].c.data[i]) ? "white" : "red"
42-
for i=1:nv(graph)]), 5);
43-
44-
Compose.set_default_graphic_size(18cm, 4cm)
45-
46-
Compose.compose(context(),
47-
ntuple(k->(context((k-1)/5, 0.0, 1.2/5, 1.0), imgs_max5[k]), 5)...)
48-
36+
# Let us visually check these configurations
37+
show_gallery(graph, (1, 5); locs=locations, vertex_configs=[max5_configs.orders[k].c.data for k=1:5])
4938

0 commit comments

Comments
 (0)