Skip to content

Commit 677f002

Browse files
committed
update
1 parent 1d9dd7c commit 677f002

File tree

4 files changed

+18
-13
lines changed

4 files changed

+18
-13
lines changed

examples/Coloring.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,14 @@ is_good_vertex_coloring(graph, single_solution.c.data)
5858

5959
vertex_color_map = Dict(0=>"red", 1=>"green", 2=>"blue")
6060

61-
show_graph(graph; locs=locations, vertex_colors=[vertex_color_map[Int(c)] for c in single_solution.c.data])
61+
show_graph(graph; locs=locations, vertex_colors=[vertex_color_map[Int(c)]
62+
for c in single_solution.c.data])
6263

6364
# 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.
6465
linegraph = line_graph(graph)
6566

66-
show_graph(linegraph; locs=[0.5 .* (locations[e.src] .+ locations[e.dst]) for e in edges(graph)])
67+
show_graph(linegraph; locs=[0.5 .* (locations[e.src] .+ locations[e.dst])
68+
for e in edges(graph)])
6769

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

examples/IndependentSet.jl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ max_config = solve(problem, SingleConfigMax(; bounded=false))[]
8686
# The return value contains a bit string, and one should read this bit string from left to right.
8787
# Having value 1 at i-th bit means vertex ``i`` is in the maximum independent set.
8888
# One can visualize this MIS with the following function.
89-
show_graph(graph; locs=locations, vertex_colors=[iszero(max_config.c.data[i]) ? "white" : "red"
90-
for i=1:nv(graph)])
89+
show_graph(graph; locs=locations, vertex_colors=
90+
[iszero(max_config.c.data[i]) ? "white" : "red" for i=1:nv(graph)])
9191

9292
# ##### enumeration of all MISs
9393
# There are two approaches to enumerate all best-K solutions.
@@ -99,11 +99,12 @@ using Compose
9999
m = length(all_max_configs.c)
100100

101101
imgs = ntuple(k->show_graph(graph;
102-
locs=locations, scale=0.25,
103-
vertex_colors=[iszero(all_max_configs.c[k][i]) ? "white" : "red"
104-
for i=1:nv(graph)]), m);
102+
locs=locations, scale=0.25,
103+
vertex_colors=[iszero(all_max_configs.c[k][i]) ? "white" : "red"
104+
for i=1:nv(graph)]), m);
105105

106-
Compose.set_default_graphic_size(18cm, 4cm); Compose.compose(context(), ntuple(k->(context((k-1)/m, 0.0, 1.2/m, 1.0), imgs[k]), m)...)
106+
Compose.set_default_graphic_size(18cm, 4cm); Compose.compose(context(),
107+
ntuple(k->(context((k-1)/m, 0.0, 1.2/m, 1.0), imgs[k]), m)...)
107108

108109
# ##### enumeration of all IS configurations
109110
all_independent_sets = solve(problem, ConfigsAll())[]

examples/Matching.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ matching_poly = solve(problem, GraphPolynomial())[]
6969
match_config = solve(problem, SingleConfigMax())[]
7070

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

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

examples/MaximalIS.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,12 @@ max_config = solve(problem, GraphPolynomial())[]
6262
maximal_configs = solve(problem, ConfigsAll())[]
6363

6464
imgs = ntuple(k->show_graph(graph;
65-
locs=locations, scale=0.25,
66-
vertex_colors=[iszero(maximal_configs[k][i]) ? "white" : "red"
67-
for i=1:nv(graph)]), length(maximal_configs));
65+
locs=locations, scale=0.25,
66+
vertex_colors=[iszero(maximal_configs[k][i]) ? "white" : "red"
67+
for i=1:nv(graph)]), length(maximal_configs));
6868

69-
Compose.set_default_graphic_size(18cm, 12cm); Compose.compose(context(), ntuple(k->(context((mod1(k,5)-1)/5, ((k-1)÷5)/3, 1.2/5, 1.0/3), imgs[k]), 15)...)
69+
Compose.set_default_graphic_size(18cm, 12cm); Compose.compose(context(),
70+
ntuple(k->(context((mod1(k,5)-1)/5, ((k-1)÷5)/3, 1.2/5, 1.0/3), imgs[k]), 15)...)
7071

7172
# 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.
7273
cliques = maximal_cliques(complement(graph))

0 commit comments

Comments
 (0)