Skip to content

Commit 33b2300

Browse files
committed
update
1 parent b40b721 commit 33b2300

File tree

12 files changed

+31
-46
lines changed

12 files changed

+31
-46
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ DocStringExtensions = "0.8, 0.9"
3737
FFTW = "1.4"
3838
Graphs = "1.7"
3939
LinearAlgebra = "1"
40-
LuxorGraphPlot = "0.3"
40+
LuxorGraphPlot = "0.4"
4141
OMEinsum = "0.8"
4242
Polynomials = "4"
4343
Primes = "0.5"

examples/Coloring.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@ graph = Graphs.smallgraph(:petersen)
1313

1414
# We can visualize this graph using the following function
1515
rot15(a, b, i::Int) = cos(2i*π/5)*a + sin(2i*π/5)*b, cos(2i*π/5)*b - sin(2i*π/5)*a
16-
17-
locations = [[rot15(0.0, 2.0, i) for i=0:4]..., [rot15(0.0, 1.0, i) for i=0:4]...]
18-
19-
show_graph(graph; locs=locations, format=:svg)
16+
locations = [[rot15(0.0, 60.0, i) for i=0:4]..., [rot15(0.0, 30, i) for i=0:4]...]
17+
show_graph(graph, locations; format=:svg)
2018

2119
# ## Generic tensor network representation
2220
# We can define the 3-coloring problem with the [`Coloring`](@ref) type as

examples/DominatingSet.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@ graph = Graphs.smallgraph(:petersen)
1616

1717
# We can visualize this graph using the following function
1818
rot15(a, b, i::Int) = cos(2i*π/5)*a + sin(2i*π/5)*b, cos(2i*π/5)*b - sin(2i*π/5)*a
19-
20-
locations = [[rot15(0.0, 2.0, i) for i=0:4]..., [rot15(0.0, 1.0, i) for i=0:4]...]
21-
22-
show_graph(graph; locs=locations, format=:svg)
19+
locations = [[rot15(0.0, 60.0, i) for i=0:4]..., [rot15(0.0, 30, i) for i=0:4]...]
20+
show_graph(graph, locations; format=:svg)
2321

2422
# ## Generic tensor network representation
2523
# We can use [`DominatingSet`](@ref) to construct the tensor network for solving the dominating set problem as

examples/IndependentSet.jl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ graph = Graphs.smallgraph(:petersen)
1212
# We can visualize this graph using the [`show_graph`](@ref) function
1313
## set the vertex locations manually instead of using the default spring layout
1414
rot15(a, b, i::Int) = cos(2i*π/5)*a + sin(2i*π/5)*b, cos(2i*π/5)*b - sin(2i*π/5)*a
15-
16-
locations = [[rot15(0.0, 2.0, i) for i=0:4]..., [rot15(0.0, 1.0, i) for i=0:4]...]
17-
18-
show_graph(graph; locs=locations, format=:svg)
15+
locations = [[rot15(0.0, 60.0, i) for i=0:4]..., [rot15(0.0, 30, i) for i=0:4]...]
16+
show_graph(graph, locations; format=:svg)
1917

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

123121
# 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.
124122
# We can visualize this MIS with the following function.
125-
show_graph(graph; locs=locations, format=:svg, vertex_colors=
123+
show_graph(graph, locations; format=:svg, vertex_colors=
126124
[iszero(single_solution[i]) ? "white" : "red" for i=1:nv(graph)])
127125

128126
# ##### Enumerate all solutions and best several solutions

examples/Matching.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ graph = Graphs.smallgraph(:petersen)
1414

1515
# We can visualize this graph using the following function
1616
rot15(a, b, i::Int) = cos(2i*π/5)*a + sin(2i*π/5)*b, cos(2i*π/5)*b - sin(2i*π/5)*a
17-
locations = [[rot15(0.0, 2.0, i) for i=0:4]..., [rot15(0.0, 1.0, i) for i=0:4]...]
18-
show_graph(graph; locs=locations, format=:svg)
17+
locations = [[rot15(0.0, 60.0, i) for i=0:4]..., [rot15(0.0, 30, i) for i=0:4]...]
18+
show_graph(graph, locations; format=:svg)
1919

2020
# ## Generic tensor network representation
2121
# We can define the matching problem with the [`Matching`](@ref) type as

examples/MaxCut.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ graph = Graphs.smallgraph(:petersen)
1717

1818
# We can visualize this graph using the following function
1919
rot15(a, b, i::Int) = cos(2i*π/5)*a + sin(2i*π/5)*b, cos(2i*π/5)*b - sin(2i*π/5)*a
20-
locations = [[rot15(0.0, 2.0, i) for i=0:4]..., [rot15(0.0, 1.0, i) for i=0:4]...]
21-
show_graph(graph; locs=locations, format=:svg)
20+
locations = [[rot15(0.0, 60.0, i) for i=0:4]..., [rot15(0.0, 30, i) for i=0:4]...]
21+
show_graph(graph, locations; format=:svg)
2222

2323
# ## Generic tensor network representation
2424
# We can define the cutting problem with the [`MaxCut`](@ref) type as

examples/MaximalIS.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ graph = Graphs.smallgraph(:petersen)
1515

1616
# We can visualize this graph using the following function
1717
rot15(a, b, i::Int) = cos(2i*π/5)*a + sin(2i*π/5)*b, cos(2i*π/5)*b - sin(2i*π/5)*a
18-
locations = [[rot15(0.0, 2.0, i) for i=0:4]..., [rot15(0.0, 1.0, i) for i=0:4]...]
19-
show_graph(graph; locs=locations, format=:svg)
18+
locations = [[rot15(0.0, 60.0, i) for i=0:4]..., [rot15(0.0, 30, i) for i=0:4]...]
19+
show_graph(graph, locations; format=:svg)
2020

2121
# ## Generic tensor network representation
2222
# We can use [`MaximalIS`](@ref) to construct the tensor network for solving the maximal independent set problem as

examples/PaintShop.jl

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,13 @@ sequence = collect("iadgbeadfcchghebif")
1818

1919
# We can visualize this paint shop problem as a graph
2020
rot(a, b, θ) = cos(θ)*a + sin(θ)*b, cos(θ)*b - sin(θ)*a
21-
22-
locations = [rot(0.0, 2.0, -0.25π - 1.5*π*(i-0.5)/length(sequence)) for i=1:length(sequence)]
23-
21+
locations = [rot(0.0, 100.0, -0.25π - 1.5*π*(i-0.5)/length(sequence)) for i=1:length(sequence)]
2422
graph = path_graph(length(sequence))
2523
for i=1:length(sequence)
2624
j = findlast(==(sequence[i]), sequence)
2725
i != j && add_edge!(graph, i, j)
2826
end
29-
30-
show_graph(graph; locs=locations, texts=string.(sequence), format=:svg, edge_colors=
27+
show_graph(graph, locations; texts=string.(sequence), format=:svg, edge_colors=
3128
[sequence[e.src] == sequence[e.dst] ? "blue" : "black" for e in edges(graph)])
3229

3330
# Vertices connected by blue edges must have different colors,

examples/SpinGlass.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ graph = Graphs.smallgraph(:petersen)
2121

2222
# We can visualize this graph using the following function
2323
rot15(a, b, i::Int) = cos(2i*π/5)*a + sin(2i*π/5)*b, cos(2i*π/5)*b - sin(2i*π/5)*a
24-
locations = [[rot15(0.0, 2.0, i) for i=0:4]..., [rot15(0.0, 1.0, i) for i=0:4]...]
25-
show_graph(graph; locs=locations, format=:svg)
24+
locations = [[rot15(0.0, 60.0, i) for i=0:4]..., [rot15(0.0, 30, i) for i=0:4]...]
25+
show_graph(graph, locations; format=:svg)
2626

2727
# ## Generic tensor network representation
2828
# An anti-ferromagnetic spin glass problem can be defined with the [`SpinGlass`](@ref) type as
@@ -86,7 +86,7 @@ Emin_verify = spinglass_energy(spinglass, ground_state)
8686

8787
# You should see a consistent result as above `Emin`.
8888

89-
show_graph(graph; locs=locations, vertex_colors=[
89+
show_graph(graph, locations; vertex_colors=[
9090
iszero(ground_state[i]) ? "white" : "red" for i=1:nv(graph)], format=:svg)
9191

9292
# In the plot, the red vertices are the ones with spin value `-1` (or `1` in the boolean representation).

examples/weighted.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ max_config_weighted = solve(problem, SingleConfigMax())[]
2020

2121
# Let us visualize the solution.
2222
rot15(a, b, i::Int) = cos(2i*π/5)*a + sin(2i*π/5)*b, cos(2i*π/5)*b - sin(2i*π/5)*a
23-
locations = [[rot15(0.0, 2.0, i) for i=0:4]..., [rot15(0.0, 1.0, i) for i=0:4]...]
24-
show_graph(graph; locs=locations, format=:svg, vertex_colors=
23+
locations = [[rot15(0.0, 60.0, i) for i=0:4]..., [rot15(0.0, 30, i) for i=0:4]...]
24+
show_graph(graph, locations; format=:svg, vertex_colors=
2525
[iszero(max_config_weighted.c.data[i]) ? "white" : "red" for i=1:nv(graph)])
2626

2727
# The only solution space property that can not be defined for general real-weighted (not including integer-weighted) graphs is the [`GraphPolynomial`](@ref).

0 commit comments

Comments
 (0)