Skip to content

Commit 8d1b541

Browse files
committed
use svg
1 parent 6e603aa commit 8d1b541

File tree

8 files changed

+19
-19
lines changed

8 files changed

+19
-19
lines changed

examples/Coloring.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ rot15(a, b, i::Int) = cos(2i*π/5)*a + sin(2i*π/5)*b, cos(2i*π/5)*b - sin(2i*
1616

1717
locations = [[rot15(0.0, 2.0, i) for i=0:4]..., [rot15(0.0, 1.0, i) for i=0:4]...]
1818

19-
show_graph(graph; locs=locations)
19+
show_graph(graph; locs=locations, format=:svg)
2020

2121
# ## Generic tensor network representation
2222
#
@@ -55,14 +55,14 @@ is_vertex_coloring(graph, single_solution.c.data)
5555

5656
vertex_color_map = Dict(0=>"red", 1=>"green", 2=>"blue")
5757

58-
show_graph(graph; locs=locations, vertex_colors=[vertex_color_map[Int(c)]
58+
show_graph(graph; locs=locations, format=:svg, vertex_colors=[vertex_color_map[Int(c)]
5959
for c in single_solution.c.data])
6060

6161
# Let us try to solve the same issue on its line graph, a graph that generated by mapping an edge to a vertex and two edges sharing a common vertex will be connected.
6262
linegraph = line_graph(graph)
6363

6464
show_graph(linegraph; locs=[0.5 .* (locations[e.src] .+ locations[e.dst])
65-
for e in edges(graph)])
65+
for e in edges(graph)], format=:svg)
6666

6767
# Let us construct the tensor network and see if there are solutions.
6868
lineproblem = Coloring{3}(linegraph);

examples/DominatingSet.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ rot15(a, b, i::Int) = cos(2i*π/5)*a + sin(2i*π/5)*b, cos(2i*π/5)*b - sin(2i*
1919

2020
locations = [[rot15(0.0, 2.0, i) for i=0:4]..., [rot15(0.0, 1.0, i) for i=0:4]...]
2121

22-
show_graph(graph; locs=locations)
22+
show_graph(graph; locs=locations, format=:svg)
2323

2424
# ## Generic tensor network representation
2525
# We can use [`DominatingSet`](@ref) to construct the tensor network for solving the dominating set problem as
@@ -72,7 +72,7 @@ all(c->is_dominating_set(graph, c), min_configs)
7272

7373
#
7474

75-
show_gallery(graph, (2, 5); locs=locations, vertex_configs=min_configs)
75+
show_gallery(graph, (2, 5); locs=locations, vertex_configs=min_configs, format=:svg)
7676

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

examples/IndependentSet.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ rot15(a, b, i::Int) = cos(2i*π/5)*a + sin(2i*π/5)*b, cos(2i*π/5)*b - sin(2i*
1515

1616
locations = [[rot15(0.0, 2.0, i) for i=0:4]..., [rot15(0.0, 1.0, i) for i=0:4]...]
1717

18-
show_graph(graph; locs=locations)
18+
show_graph(graph; locs=locations, format=:svg)
1919

2020
# The graphical display is available in the following editors
2121
# * a [VSCode](https://github.com/julia-vscode/julia-vscode) editor,
@@ -118,7 +118,7 @@ single_solution = max_config.c.data
118118

119119
# This bit string should be read from left to right, with the i-th bit being 1 (0) to indicate the i-th vertex is present (absent) in the set.
120120
# We can visualize this MIS with the following function.
121-
show_graph(graph; locs=locations, vertex_colors=
121+
show_graph(graph; locs=locations, format=:svg, vertex_colors=
122122
[iszero(single_solution[i]) ? "white" : "red" for i=1:nv(graph)])
123123

124124
# ##### Enumerate all solutions and best several solutions
@@ -131,7 +131,7 @@ all_max_configs = solve(problem, ConfigsMax(; bounded=true))[]
131131
all_max_configs.c.data
132132

133133
# These solutions can be visualized with the [`show_gallery`](@ref) function.
134-
show_gallery(graph, (1, length(all_max_configs.c)); locs=locations, vertex_configs=all_max_configs.c);
134+
show_gallery(graph, (1, length(all_max_configs.c)); locs=locations, vertex_configs=all_max_configs.c, format=:svg)
135135

136136
# We can use [`ConfigsAll`](@ref) to enumerate all sets satisfying the independence constraint.
137137
all_independent_sets = solve(problem, ConfigsAll())[]

examples/Matching.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ rot15(a, b, i::Int) = cos(2i*π/5)*a + sin(2i*π/5)*b, cos(2i*π/5)*b - sin(2i*
1717

1818
locations = [[rot15(0.0, 2.0, i) for i=0:4]..., [rot15(0.0, 1.0, i) for i=0:4]...]
1919

20-
show_graph(graph; locs=locations)
20+
show_graph(graph; locs=locations, format=:svg)
2121

2222
# ## Generic tensor network representation
2323
# We construct the tensor network for the matching problem by typing
@@ -66,7 +66,7 @@ matching_poly = solve(problem, GraphPolynomial())[]
6666
match_config = solve(problem, SingleConfigMax())[]
6767

6868
# Let us show the result by coloring the matched edges to red
69-
show_graph(graph; locs=locations, edge_colors=
69+
show_graph(graph; locs=locations, format=:svg, edge_colors=
7070
[isone(match_config.c.data[i]) ? "red" : "black" for i=1:ne(graph)])
7171

7272
# where we use edges with red color to related pairs of matched vertices.

examples/MaxCut.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ rot15(a, b, i::Int) = cos(2i*π/5)*a + sin(2i*π/5)*b, cos(2i*π/5)*b - sin(2i*
2020

2121
locations = [[rot15(0.0, 2.0, i) for i=0:4]..., [rot15(0.0, 1.0, i) for i=0:4]...]
2222

23-
show_graph(graph; locs=locations)
23+
show_graph(graph; locs=locations, format=:svg)
2424

2525
# ## Generic tensor network representation
2626
# We define the cutting problem as
@@ -69,6 +69,6 @@ max_cut_size_verify = cut_size(graph, max_vertex_config)
6969
# You should see a consistent result as above `max_cut_size`.
7070

7171
show_graph(graph; locs=locations, vertex_colors=[
72-
iszero(max_vertex_config[i]) ? "white" : "red" for i=1:nv(graph)])
72+
iszero(max_vertex_config[i]) ? "white" : "red" for i=1:nv(graph)], format=:svg)
7373

7474
# where red vertices and white vertices are separated by the cut.

examples/MaximalIS.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ rot15(a, b, i::Int) = cos(2i*π/5)*a + sin(2i*π/5)*b, cos(2i*π/5)*b - sin(2i*
1818

1919
locations = [[rot15(0.0, 2.0, i) for i=0:4]..., [rot15(0.0, 1.0, i) for i=0:4]...]
2020

21-
show_graph(graph; locs=locations)
21+
show_graph(graph; locs=locations, format=:svg)
2222

2323
# ## Generic tensor network representation
2424
# We can use [`MaximalIS`](@ref) to construct the tensor network for solving the maximal independent set problem as
@@ -73,7 +73,7 @@ all(c->is_maximal_independent_set(graph, c), maximal_configs)
7373

7474
#
7575

76-
show_gallery(graph, (3, 5); locs=locations, vertex_configs=maximal_configs)
76+
show_gallery(graph, (3, 5); locs=locations, vertex_configs=maximal_configs, format=:svg)
7777

7878
# 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.
7979
cliques = maximal_cliques(complement(graph))
@@ -84,7 +84,7 @@ cliques = maximal_cliques(complement(graph))
8484
# It is the [`ConfigsMin`](@ref) property in the program.
8585
minimum_maximal_configs = solve(problem, ConfigsMin())[].c
8686

87-
show_gallery(graph, (2, 5); locs=locations, vertex_configs=minimum_maximal_configs)
87+
show_gallery(graph, (2, 5); locs=locations, vertex_configs=minimum_maximal_configs, format=:svg)
8888

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

examples/PaintShop.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ for i=1:length(sequence)
2727
i != j && add_edge!(graph, i, j)
2828
end
2929

30-
show_graph(graph; locs=locations, texts=string.(sequence), edge_colors=
30+
show_graph(graph; locs=locations, texts=string.(sequence), format=:svg, edge_colors=
3131
[sequence[e.src] == sequence[e.dst] ? "blue" : "black" for e in edges(graph)])
3232

3333
# Vertices connected by blue edges must have different colors,
@@ -90,7 +90,7 @@ best_configs = solve(problem, ConfigsMin())[]
9090

9191
painting1 = paint_shop_coloring_from_config(problem, best_configs.c.data[1])
9292

93-
show_graph(graph; locs=locations, texts=string.(sequence),
93+
show_graph(graph; locs=locations, format=:svg, texts=string.(sequence),
9494
edge_colors=[sequence[e.src] == sequence[e.dst] ? "blue" : "black" for e in edges(graph)],
9595
vertex_colors=[isone(c) ? "red" : "black" for c in painting1], vertex_text_color="white")
9696

examples/weighted.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ rot15(a, b, i::Int) = cos(2i*π/5)*a + sin(2i*π/5)*b, cos(2i*π/5)*b - sin(2i*
1919

2020
locations = [[rot15(0.0, 2.0, i) for i=0:4]..., [rot15(0.0, 1.0, i) for i=0:4]...]
2121

22-
show_graph(graph; locs=locations, vertex_colors=
22+
show_graph(graph; locs=locations, format=:svg, vertex_colors=
2323
[iszero(max_config_weighted.c.data[i]) ? "white" : "red" for i=1:nv(graph)])
2424

2525
# The only solution space property that can not be defined for general real-weighted (not including integer-weighted) graphs is the [`GraphPolynomial`](@ref).
@@ -39,5 +39,5 @@ max5_configs = solve(problem, SingleConfigMax(5))[]
3939
max5_configs.orders
4040

4141
# Let us visually check these configurations
42-
show_gallery(graph, (1, 5); locs=locations, vertex_configs=[max5_configs.orders[k].c.data for k=1:5])
42+
show_gallery(graph, (1, 5); locs=locations, format=:svg, vertex_configs=[max5_configs.orders[k].c.data for k=1:5])
4343

0 commit comments

Comments
 (0)