Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 318e814

Browse files
authoredJun 27, 2022
change maxcut to spinglass (#49)
1 parent 02b2197 commit 318e814

File tree

14 files changed

+207
-144
lines changed

14 files changed

+207
-144
lines changed
 

‎Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "GenericTensorNetworks"
22
uuid = "3521c873-ad32-4bb4-b63d-f4f178f42b49"
33
authors = ["GiggleLiu <cacate0129@gmail.com> and contributors"]
4-
version = "1.0.6"
4+
version = "1.1.0"
55

66
[deps]
77
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"

‎README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The *solution space properties* include
1212
* The enumeration of solutions at certain sizes.
1313
* The direct sampling of solutions at certain sizes.
1414

15-
The solvable problems include [Independent set problem](https://queracomputing.github.io/GenericTensorNetworks.jl/dev/generated/IndependentSet/), [Maximal independent set problem](https://queracomputing.github.io/GenericTensorNetworks.jl/dev/generated/MaximalIS/), [Cutting problem (Spin-glass problem)](https://queracomputing.github.io/GenericTensorNetworks.jl/dev/generated/MaxCut/), [Vertex matching problem](https://queracomputing.github.io/GenericTensorNetworks.jl/dev/generated/Matching/), [Binary paint shop problem](https://queracomputing.github.io/GenericTensorNetworks.jl/dev/generated/PaintShop/), [Coloring problem](https://queracomputing.github.io/GenericTensorNetworks.jl/dev/generated/Coloring/), [Dominating set problem](https://queracomputing.github.io/GenericTensorNetworks.jl/dev/generated/DominatingSet/), [Set packing problem](https://queracomputing.github.io/GenericTensorNetworks.jl/dev/generated/SetPacking/), [Satisfiability problem](https://queracomputing.github.io/GenericTensorNetworks.jl/dev/generated/Satisfiability/) and [Set covering problem](https://queracomputing.github.io/GenericTensorNetworks.jl/dev/generated/SetCovering/).
15+
The solvable problems include [Independent set problem](https://queracomputing.github.io/GenericTensorNetworks.jl/dev/generated/IndependentSet/), [Maximal independent set problem](https://queracomputing.github.io/GenericTensorNetworks.jl/dev/generated/MaximalIS/), [Cutting problem (Spin-glass problem)](https://queracomputing.github.io/GenericTensorNetworks.jl/dev/generated/SpinGlass/), [Vertex matching problem](https://queracomputing.github.io/GenericTensorNetworks.jl/dev/generated/Matching/), [Binary paint shop problem](https://queracomputing.github.io/GenericTensorNetworks.jl/dev/generated/PaintShop/), [Coloring problem](https://queracomputing.github.io/GenericTensorNetworks.jl/dev/generated/Coloring/), [Dominating set problem](https://queracomputing.github.io/GenericTensorNetworks.jl/dev/generated/DominatingSet/), [Set packing problem](https://queracomputing.github.io/GenericTensorNetworks.jl/dev/generated/SetPacking/), [Satisfiability problem](https://queracomputing.github.io/GenericTensorNetworks.jl/dev/generated/Satisfiability/) and [Set covering problem](https://queracomputing.github.io/GenericTensorNetworks.jl/dev/generated/SetCovering/).
1616

1717
## Installation
1818
<p>

‎docs/make.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ makedocs(;
4848
"Problems" => [
4949
"Independent set problem" => "generated/IndependentSet.md",
5050
"Maximal independent set problem" => "generated/MaximalIS.md",
51-
"Cutting problem" => "generated/MaxCut.md",
52-
"Vertex Matching problem" => "generated/Matching.md",
51+
"Spin glass problem" => "generated/SpinGlass.md",
52+
"Vertex matching problem" => "generated/Matching.md",
5353
"Binary paint shop problem" => "generated/PaintShop.md",
5454
"Coloring problem" => "generated/Coloring.md",
5555
"Dominating set problem" => "generated/DominatingSet.md",

‎docs/serve.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ function serve(;host::String="0.0.0.0", port::Int=8000)
1111
skip_dirs=[
1212
joinpath("docs", "src", "assets"),
1313
joinpath("docs", "src", "generated"),
14+
joinpath("docs", "src", "notebooks"),
15+
joinpath("docs", "build"),
1416
],
1517
literate="examples",
1618
host=\"$host\",

‎docs/src/performancetips.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,9 @@ The graphs in all benchmarks are random three-regular graphs, which have treewid
191191
Panel (a) shows the time and space complexity of tensor network contraction for different graph sizes. The contraction order is obtained using the `TreeSA` algorithm that implemented in [OMEinsumContractionOrders](https://github.com/TensorBFS/OMEinsumContractionOrders.jl). If we assume our contraction-order finding program has found the optimal treewidth, which is very likely to be true, the space complexity is the same as the treewidth of the problem graph.
192192
Slicing technique has been used for graphs with space complexity greater than ``2^{27}`` (above the yellow dashed line) to fit the computation into a 16GB memory. One can see that all the computation times in panels (b), (c), and (d) have a strong correlation with the predicted time and space complexity.
193193
While in panel (d), the computation time of configuration enumeration also strongly correlates with other factors such as the configuration space size.
194-
Among these benchmarks, computational tasks with data types real numbers, complex numbers, or [Tropical](@ref) numbers (CPU only) can utilize fast basic linear algebra subprograms (BLAS) functions. These tasks usually compute much faster than ones with other element types in the same category.
194+
Among these benchmarks, computational tasks with data types real numbers, complex numbers, or [`Tropical`](@ref) numbers (CPU only) can utilize fast basic linear algebra subprograms (BLAS) functions. These tasks usually compute much faster than ones with other element types in the same category.
195195
Immutable data types with no reference to other values can be compiled to GPU devices that run much faster than CPUs in all cases when the problem scale is big enough.
196-
These data types do not include those defined in [Polynomial](@ref), [ConfigEnumerator](@ref), [ExtendedTropical](@ref) and [SumProductTree](@ref) or a data type containing them as a part.
196+
These data types do not include those defined in [`Polynomial`](@ref), [`ConfigEnumerator`](@ref), [`ExtendedTropical`](@ref) and [`SumProductTree`](@ref) or a data type containing them as a part.
197197
In panel (c), one can see the Fourier transformation-based method is the fastest in computing the independence polynomial,
198198
but it may suffer from round-off errors. The finite field (GF(p)) approach is the only method that does not have round-off errors and can be run on a GPU.
199199
In panel (d), one can see the technique to bound the enumeration space (see paper) improves the performance for more than one order of magnitude in enumerating the MISs. The bounding technique can also reduce the memory usage significantly, without which the largest computable graph size is only ``\sim150`` on a device with 32GB main memory.

‎docs/src/ref.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ MaximalIS
88
Matching
99
Coloring
1010
DominatingSet
11-
MaxCut
11+
SpinGlass
1212
PaintShop
1313
Satisfiability
1414
SetCovering
@@ -43,6 +43,7 @@ is_set_covering
4343
is_set_packing
4444
4545
cut_size
46+
spinglass_energy
4647
num_paint_shop_color_switch
4748
paint_shop_coloring_from_config
4849
mis_compactify!
Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
1-
# # Cutting problem (Spin-glass problem)
1+
# # Spin-glass problem (Cutting problem)
22

33
# !!! note
44
# It is highly recommended to read the [Independent set problem](@ref) chapter before reading this one.
55

66
# ## Problem definition
7-
# In graph theory, a [cut](https://en.wikipedia.org/wiki/Cut_(graph_theory)) is a partition of the vertices of a graph into two disjoint subsets.
8-
# It is closely related to the [spin-glass](https://en.wikipedia.org/wiki/Spin_glass) problem in physics.
9-
# Finding the maximum cut is NP-Hard, where a maximum cut is a cut whose size is at least the size of any other cut,
7+
# Let ``G=(V, E)`` be a graph, the [spin-glass](https://en.wikipedia.org/wiki/Spin_glass) problem in physics is characterized by the following energy function
8+
# ```math
9+
# H = - \sum_{ij \in E} J_{ij} s_i s_j + \sum_{i \in V} h_i s_i,
10+
# ```
11+
# where ``h_i`` is an onsite energy term associated with spin ``s_i \in \{0, 1\}``, and ``J_{ij}`` is the coupling strength between spins ``s_i`` and ``s_j``.
12+
#
13+
# The spin glass problem very close related to the cutting problem in graph theory.
14+
# A [cut](https://en.wikipedia.org/wiki/Cut_(graph_theory)) is a partition of the vertices of a graph into two disjoint subsets.
15+
# Finding the maximum cut (the spin glass maximum energy) is NP-Hard, where a maximum cut is a cut whose size is at least the size of any other cut,
1016
# where the size of a cut is the number of edges (or the sum of weights on edges) crossing the cut.
1117

1218
using GenericTensorNetworks, Graphs
1319

14-
# In the following, we are going to defined an cutting problem for the Petersen graph.
20+
# In the following, we are going to defined an spin glass problem for the Petersen graph.
1521

1622
graph = Graphs.smallgraph(:petersen)
1723

@@ -23,52 +29,52 @@ locations = [[rot15(0.0, 2.0, i) for i=0:4]..., [rot15(0.0, 1.0, i) for i=0:4]..
2329
show_graph(graph; locs=locations, format=:svg)
2430

2531
# ## Generic tensor network representation
26-
# We define the cutting problem as
27-
problem = MaxCut(graph);
32+
# We define the spin glass problem as
33+
problem = SpinGlass(graph);
2834

2935
# ### Theory (can skip)
3036
#
3137
# For a vertex ``v\in V``, we define a boolean degree of freedom ``s_v\in\{0, 1\}``.
32-
# Then the maximum cutting problem can be encoded to tensor networks by mapping an edge ``(i,j)\in E`` to an edge matrix labelled by ``s_is_j``
38+
# Then the spin glass problem can be encoded to tensor networks by mapping an edge ``(i,j)\in E`` to an edge matrix labelled by ``s_is_j``
3339
# ```math
3440
# B(x_{\langle i, j\rangle}) = \left(\begin{matrix}
3541
# 1 & x_{\langle i, j\rangle}^{w_{\langle i,j \rangle}}\\
3642
# x_{\langle i, j\rangle}^{w_{\langle i,j \rangle}} & 1
3743
# \end{matrix}\right),
3844
# ```
39-
# If and only if there is a cut on edge ``(i, j)``,
45+
# If and only if the spin configuration is anti-parallel on edge ``(i, j)``,
4046
# this tensor contributes a factor ``x_{\langle i, j\rangle}^{w_{\langle i,j \rangle}}``,
4147
# where ``w_{\langle i,j\rangle}`` is the weight of this edge.
4248
# Similar to other problems, we can define a polynomial about edges variables by setting ``x_{\langle i, j\rangle} = x``,
43-
# where its k-th coefficient is two times the number of configurations of cut size k.
49+
# where its k-th coefficient is two times the number of configurations with energy (cut size) k.
4450

4551
# Its contraction time space complexity is ``2^{{\rm tw}(G)}``, where ``{\rm tw(G)}`` is the [tree-width](https://en.wikipedia.org/wiki/Treewidth) of ``G``.
4652

4753
# ## Solving properties
48-
# ### Maximum cut size ``\gamma(G)``
49-
max_cut_size = solve(problem, SizeMax())[]
54+
# ### Maximum energy ``E^*(G)``
55+
Emax = solve(problem, SizeMax())[]
5056

5157
# ### Counting properties
5258
# ##### graph polynomial
53-
# The graph polynomial defined for the cutting problem is
59+
# The graph polynomial defined for the spin glass problem is
5460
# ```math
55-
# C(G, x) = \sum_{k=0}^{\gamma(G)} c_k x^k,
61+
# C(G, x) = \sum_{k=0}^{E^*(G)} c_k x^k,
5662
# ```
5763
# where ``\alpha(G)`` is the maximum independent set size,
58-
# ``c_k/2`` is the number of cuts of size ``k`` in graph ``G=(V,E)``.
64+
# ``c_k/2`` is the number of anti-parallel edges (cuts) of size ``k`` in graph ``G=(V,E)``.
5965
# Since the variable ``x`` is defined on edges,
6066
# the coefficients of the polynomial is the number of configurations having different number of anti-parallel edges.
6167
max_config = solve(problem, GraphPolynomial())[]
6268

6369
# ### Configuration properties
64-
# ##### finding one max cut solution
70+
# ##### finding one solution with highest energy
6571
max_vertex_config = solve(problem, SingleConfigMax())[].c.data
6672

67-
max_cut_size_verify = cut_size(graph, max_vertex_config)
73+
Emax_verify = spinglass_energy(graph, max_vertex_config)
6874

69-
# You should see a consistent result as above `max_cut_size`.
75+
# You should see a consistent result as above `Emax`.
7076

7177
show_graph(graph; locs=locations, vertex_colors=[
7278
iszero(max_vertex_config[i]) ? "white" : "red" for i=1:nv(graph)], format=:svg)
7379

74-
# where red vertices and white vertices are separated by the cut.
80+
# where a red vertice and a white vertice correspond to a spin having value 1 and 0 respectively.

‎src/GenericTensorNetworks.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export GraphProblem, optimize_code, NoWeight
3434
export flavors, labels, terms, nflavor, get_weights, fixedvertices
3535
export IndependentSet, mis_compactify!, is_independent_set
3636
export MaximalIS, is_maximal_independent_set
37-
export MaxCut, cut_size
37+
export cut_size, spinglass_energy, SpinGlass
3838
export PaintShop, paintshop_from_pairs, num_paint_shop_color_switch, paint_shop_coloring_from_config
3939
export Coloring, is_vertex_coloring
4040
export Satisfiability, CNF, CNFClause, BoolVar, satisfiable, @bools, , ¬,
@@ -69,6 +69,8 @@ include("deprecate.jl")
6969
include("multiprocessing.jl")
7070
include("visualize.jl")
7171

72+
Base.@deprecate MaxCut(g::SimpleGraph; weights=NoWeight(), openvertices=(), fixedvertices=Dict{Int,Int}(), optimizer=GreedyMethod(), simplifier=nothing) SpinGlass(g; edge_weights=weights, openvertices, fixedvertices, optimizer, simplifier)
73+
7274
using Requires
7375
function __init__()
7476
@require CUDA="052768ef-5323-5732-b1bb-66c8b64840ba" include("cuda.jl")

‎src/networks/MaxCut.jl

Lines changed: 0 additions & 62 deletions
This file was deleted.

‎src/networks/SpinGlass.jl

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
"""
2+
SpinGlass{CT<:AbstractEinsum,WT<:Union{NoWieght, Vector}} <: GraphProblem
3+
SpinGlass(graph; edge_weights=NoWeight(), vertex_weights=NoWeight(), openvertices=(),
4+
optimizer=GreedyMethod(), simplifier=nothing,
5+
fixedvertices=Dict()
6+
)
7+
8+
The [spin glass](https://psychic-meme-f4d866f8.pages.github.io/dev/generated/SpinGlass.html) problem (or cutting problem).
9+
10+
Positional arguments
11+
-------------------------------
12+
* `graph` is the problem graph.
13+
14+
Keyword arguments
15+
-------------------------------
16+
* `edge_weights` are associated with the edges of the `graph`, also known as the coupling strengths in spin glasses.
17+
* `vertex_weights` are associated with the vertices of the `graph`, also known the onsite energy term in spin glasses.
18+
* `optimizer` and `simplifier` are for tensor network optimization, check [`optimize_code`](@ref) for details.
19+
* `fixedvertices` is a dict to specify the values of degree of freedoms, where a value can be `0` (in one side of the cut) or `1` (in the other side of the cut).
20+
* `openvertices` is a tuple of labels to specify the output tensor. Theses degree of freedoms will not be contracted.
21+
"""
22+
struct SpinGlass{CT<:AbstractEinsum,WT1<:Union{NoWeight, Vector},WT2<:Union{ZeroWeight, Vector}} <: GraphProblem
23+
code::CT
24+
graph::SimpleGraph{Int}
25+
edge_weights::WT1
26+
vertex_weights::WT2
27+
fixedvertices::Dict{Int,Int}
28+
end
29+
function SpinGlass(g::SimpleGraph; edge_weights=NoWeight(), vertex_weights=ZeroWeight(), openvertices=(), fixedvertices=Dict{Int,Int}(), optimizer=GreedyMethod(), simplifier=nothing)
30+
@assert edge_weights isa NoWeight || length(edge_weights) == ne(g)
31+
@assert vertex_weights isa ZeroWeight || length(vertex_weights) == nv(g)
32+
rawcode = EinCode([
33+
map(e->[minmax(e.src,e.dst)...], Graphs.edges(g))...,
34+
map(v->[v], Graphs.vertices(g))...,
35+
], collect(Int, openvertices)) # labels for edge tensors
36+
SpinGlass(_optimize_code(rawcode, uniformsize_fix(rawcode, 2, fixedvertices), optimizer, simplifier), g, edge_weights, vertex_weights, Dict{Int,Int}(fixedvertices))
37+
end
38+
39+
flavors(::Type{<:SpinGlass}) = [0, 1]
40+
# first `ne` indices are for edge weights, last `nv` indices are for vertex weights.
41+
get_weights(gp::SpinGlass, i::Int) = i <= ne(gp.graph) ? [0, gp.edge_weights[i]] : [0, gp.vertex_weights[i-ne(gp.graph)]]
42+
terms(gp::SpinGlass) = getixsv(gp.code)
43+
labels(gp::SpinGlass) = [1:nv(gp.graph)...]
44+
fixedvertices(gp::SpinGlass) = gp.fixedvertices
45+
46+
function generate_tensors(x::T, gp::SpinGlass) where T
47+
ixs = getixsv(gp.code)
48+
l = ne(gp.graph)
49+
tensors = [
50+
Array{T}[spinglassb((Ref(x) .^ get_weights(gp, i)) ...) for i=1:l]...,
51+
add_labels!(Array{T}[Ref(x) .^ get_weights(gp, i+l) for i=1:nv(gp.graph)], ixs[l+1:end], labels(gp))...
52+
]
53+
return select_dims(tensors, ixs, fixedvertices(gp))
54+
end
55+
56+
function spinglassb(a, b)
57+
return [a b; b a]
58+
end
59+
60+
"""
61+
spinglass_energy(g::SimpleGraph, config; edge_weights=NoWeight(), vertex_weights=ZeroWeight())
62+
63+
Compute the spin glass state energy for the vertex configuration `config` (an iterator).
64+
"""
65+
function spinglass_energy(g::SimpleGraph, config; edge_weights=NoWeight(), vertex_weights=ZeroWeight())
66+
size = zero(eltype(edge_weights)) * false
67+
# coupling terms
68+
for (i, e) in enumerate(edges(g))
69+
size += (config[e.src] != config[e.dst]) * edge_weights[i]
70+
end
71+
# onsite terms
72+
for (i, v) in enumerate(vertices(g))
73+
size += config[v] * vertex_weights[i]
74+
end
75+
return size
76+
end
77+
78+
79+
"""
80+
cut_size(g::SimpleGraph, config; weights=NoWeight())
81+
82+
Compute the cut size for the vertex configuration `config` (an iterator).
83+
"""
84+
function cut_size(g::SimpleGraph, config; weights=NoWeight())
85+
size = zero(eltype(weights)) * false
86+
for (i, e) in enumerate(edges(g))
87+
size += (config[e.src] != config[e.dst]) * weights[i]
88+
end
89+
return size
90+
end

‎src/networks/networks.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ struct NoWeight end
99
Base.getindex(::NoWeight, i) = 1
1010
Base.eltype(::NoWeight) = Int
1111

12+
struct ZeroWeight end
13+
Base.getindex(::ZeroWeight, i) = 0
14+
Base.eltype(::ZeroWeight) = Int
15+
1216
######## Interfaces for graph problems ##########
1317
"""
1418
get_weights(problem::GraphProblem, sym) -> Vector
@@ -109,7 +113,7 @@ generate_tensors(::Type{GT}) where GT = length(flavors(GT))
109113

110114
include("IndependentSet.jl")
111115
include("MaximalIS.jl")
112-
include("MaxCut.jl")
116+
include("SpinGlass.jl")
113117
include("Matching.jl")
114118
include("Coloring.jl")
115119
include("PaintShop.jl")

‎test/networks/MaxCut.jl

Lines changed: 0 additions & 53 deletions
This file was deleted.

‎test/networks/SpinGlass.jl

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
using GenericTensorNetworks, Test, Graphs
2+
using GenericTensorNetworks: max_size, graph_polynomial
3+
4+
@testset "graph utils" begin
5+
g2 = SimpleGraph(3)
6+
add_edge!(g2, 1,2)
7+
for g in [smallgraph(:petersen), g2]
8+
gp = SpinGlass(g)
9+
mc = max_size(gp)
10+
config = solve(gp, SingleConfigMax())[].c.data
11+
@test spinglass_energy(g, config) == mc
12+
end
13+
g = smallgraph(:petersen)
14+
# weighted
15+
weights = collect(1:ne(g))
16+
gp = SpinGlass(g; edge_weights=weights)
17+
mc = max_size(gp)
18+
config = solve(gp, SingleConfigMax())[].c.data
19+
@test solve(gp, CountingMax())[].c == 2
20+
@test spinglass_energy(g, config; edge_weights=weights) == mc
21+
22+
# weighted Max-Cut
23+
weights = collect(1:ne(g))
24+
gp = MaxCut(g; weights)
25+
mc = max_size(gp)
26+
config = solve(gp, SingleConfigMax())[].c.data
27+
@test solve(gp, CountingMax())[].c == 2
28+
@test cut_size(g, config; weights) == mc
29+
end
30+
31+
@testset "SpinGlass" begin
32+
g = SimpleGraph(5)
33+
for (i,j) in [(1,2),(2,3),(3,4),(4,1),(1,5),(2,4)]
34+
add_edge!(g, i, j)
35+
end
36+
@test graph_polynomial(SpinGlass(g), Val(:polynomial))[] == Polynomial([2,2,4,12,10,2])
37+
@test graph_polynomial(SpinGlass(g), Val(:finitefield))[] == Polynomial([2,2,4,12,10,2])
38+
end
39+
40+
@testset "enumerating - max cut" begin
41+
g = SimpleGraph(5)
42+
for (i,j) in [(1,2),(2,3),(3,4),(4,1),(1,5),(2,4)]
43+
add_edge!(g, i, j)
44+
end
45+
code = SpinGlass(g; optimizer=GreedyMethod())
46+
res = GenericTensorNetworks.best_solutions(code; all=true)[]
47+
@test length(res.c.data) == 2
48+
@test spinglass_energy(g, res.c.data[1]) == 5
49+
end
50+
51+
@testset "fix vertices - max vut" begin
52+
g = SimpleGraph(5)
53+
for (i,j) in [(1,2),(2,3),(3,4),(4,1),(1,5),(2,4)]
54+
add_edge!(g, i, j)
55+
end
56+
fixedvertices = Dict(1=>1, 4=>0)
57+
problem = SpinGlass(g, fixedvertices=fixedvertices)
58+
optimal_config = solve(problem, ConfigsMax())[].c
59+
@test length(optimal_config) == 1
60+
@test optimal_config[1] == StaticBitVector(Array{Bool, 1}([1, 0, 1, 0, 0]))
61+
end
62+
63+
@testset "vertex weights" begin
64+
g = smallgraph(:petersen)
65+
edge_weights = collect(1:ne(g))
66+
vertex_weights = collect(1:nv(g))
67+
gp = SpinGlass(g; edge_weights, vertex_weights)
68+
69+
mc = max_size(gp)
70+
config = solve(gp, SingleConfigMax())[].c.data
71+
@test solve(gp, CountingMax())[].c == 1
72+
@test spinglass_energy(g, config; edge_weights, vertex_weights) == mc
73+
end

‎test/networks/networks.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ end
1515

1616
include("IndependentSet.jl")
1717
include("MaximalIS.jl")
18-
include("MaxCut.jl")
18+
include("SpinGlass.jl")
1919
include("PaintShop.jl")
2020
include("Coloring.jl")
2121
include("Matching.jl")

0 commit comments

Comments
 (0)
Please sign in to comment.