Skip to content

Commit c364d40

Browse files
committed
rename unweighted
1 parent 1726b79 commit c364d40

File tree

8 files changed

+25
-25
lines changed

8 files changed

+25
-25
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "GraphTensorNetworks"
22
uuid = "0978c8c2-34f6-49c7-9826-ea2cc20dabd2"
33
authors = ["GiggleLiu <cacate0129@gmail.com> and contributors"]
4-
version = "0.2.4"
4+
version = "0.2.5"
55

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

src/GraphTensorNetworks.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export line_graph
3131
# Tensor Networks (Graph problems)
3232
export GraphProblem, IndependentSet, MaximalIS, Matching,
3333
Coloring, optimize_code, set_packing, MaxCut, PaintShop,
34-
paintshop_from_pairs, UnWeighted, Satisfiability
34+
paintshop_from_pairs, NoWeight, Satisfiability
3535
export flavors, labels, terms, nflavor, get_weights
3636
export mis_compactify!, cut_size, num_paint_shop_color_switch, paint_shop_coloring_from_config
3737
export is_good_vertex_coloring

src/networks/IndependentSet.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
"""
2-
IndependentSet{CT<:AbstractEinsum,WT<:Union{UnWeighted, Vector}} <: GraphProblem
3-
IndependentSet(graph; weights=UnWeighted(), openvertices=(),
2+
IndependentSet{CT<:AbstractEinsum,WT<:Union{NoWeight, Vector}} <: GraphProblem
3+
IndependentSet(graph; weights=NoWeight(), openvertices=(),
44
optimizer=GreedyMethod(), simplifier=nothing)
55
66
The [independent set problem](https://psychic-meme-f4d866f8.pages.github.io/dev/tutorials/IndependentSet.html) in graph theory.
77
In the constructor, `weights` are the weights of vertices.
88
`openvertices` specifies labels for the output tensor.
99
`optimizer` and `simplifier` are for tensor network optimization, check [`optimize_code`](@ref) for details.
1010
"""
11-
struct IndependentSet{CT<:AbstractEinsum,WT<:Union{UnWeighted, Vector}} <: GraphProblem
11+
struct IndependentSet{CT<:AbstractEinsum,WT<:Union{NoWeight, Vector}} <: GraphProblem
1212
code::CT
1313
nv::Int
1414
weights::WT
1515
end
1616

17-
function IndependentSet(g::SimpleGraph; weights=UnWeighted(), openvertices=(), optimizer=GreedyMethod(), simplifier=nothing)
18-
@assert weights isa UnWeighted || length(weights) == nv(g)
17+
function IndependentSet(g::SimpleGraph; weights=NoWeight(), openvertices=(), optimizer=GreedyMethod(), simplifier=nothing)
18+
@assert weights isa NoWeight || length(weights) == nv(g)
1919
rawcode = EinCode([[[i] for i in Graphs.vertices(g)]..., # labels for vertex tensors
2020
[[minmax(e.src,e.dst)...] for e in Graphs.edges(g)]...], collect(Int, openvertices)) # labels for edge tensors
2121
code = _optimize_code(rawcode, uniformsize(rawcode, 2), optimizer, simplifier)
@@ -70,7 +70,7 @@ julia> res = best_solutions(gp; all=true)[]
7070
(2, {10010, 00110, 01100})ₜ
7171
```
7272
"""
73-
function set_packing(sets; weights=UnWeighted(), openvertices=(), optimizer=GreedyMethod(), simplifier=nothing)
73+
function set_packing(sets; weights=NoWeight(), openvertices=(), optimizer=GreedyMethod(), simplifier=nothing)
7474
n = length(sets)
7575
code = EinCode(vcat([[i] for i=1:n], [[i,j] for i=1:n,j=1:n if j>i && !isempty(sets[i] sets[j])]), collect(Int,openvertices))
7676
IndependentSet(_optimize_code(code, uniformsize(code, 2), optimizer, simplifier), n, weights)

src/networks/MaxCut.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
"""
2-
MaxCut{CT<:AbstractEinsum,WT<:Union{UnWeighted, Vector}} <: GraphProblem
3-
MaxCut(graph; weights=UnWeighted(), openvertices=(),
2+
MaxCut{CT<:AbstractEinsum,WT<:Union{NoWieght, Vector}} <: GraphProblem
3+
MaxCut(graph; weights=NoWeight(), openvertices=(),
44
optimizer=GreedyMethod(), simplifier=nothing)
55
66
The [cutting](https://psychic-meme-f4d866f8.pages.github.io/dev/tutorials/MaxCut.html) problem (or spin glass problem).
77
In the constructor, `weights` are the weights of edges.
88
`optimizer` and `simplifier` are for tensor network optimization, check [`optimize_code`](@ref) for details.
99
"""
10-
struct MaxCut{CT<:AbstractEinsum,WT<:Union{UnWeighted, Vector}} <: GraphProblem
10+
struct MaxCut{CT<:AbstractEinsum,WT<:Union{NoWeight, Vector}} <: GraphProblem
1111
code::CT
1212
nv::Int
1313
weights::WT
1414
end
15-
function MaxCut(g::SimpleGraph; weights=UnWeighted(), openvertices=(), optimizer=GreedyMethod(), simplifier=nothing)
16-
@assert weights isa UnWeighted || length(weights) == ne(g)
15+
function MaxCut(g::SimpleGraph; weights=NoWeight(), openvertices=(), optimizer=GreedyMethod(), simplifier=nothing)
16+
@assert weights isa NoWeight || length(weights) == ne(g)
1717
rawcode = EinCode([[minmax(e.src,e.dst)...] for e in Graphs.edges(g)], collect(Int, openvertices)) # labels for edge tensors
1818
MaxCut(_optimize_code(rawcode, uniformsize(rawcode, 2), optimizer, simplifier), nv(g), weights)
1919
end
@@ -34,11 +34,11 @@ function maxcutb(a, b)
3434
end
3535

3636
"""
37-
cut_size(g::SimpleGraph, config; weights=UnWeighted())
37+
cut_size(g::SimpleGraph, config; weights=NoWeight())
3838
3939
Compute the cut size from vertex `config` (an iterator).
4040
"""
41-
function cut_size(g::SimpleGraph, config; weights=UnWeighted())
41+
function cut_size(g::SimpleGraph, config; weights=NoWeight())
4242
size = zero(eltype(weights)) * false
4343
for (i, e) in enumerate(edges(g))
4444
size += (config[e.src] != config[e.dst]) * weights[i]

src/networks/MaximalIS.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
"""
2-
MaximalIS{CT<:AbstractEinsum,WT<:Union{UnWeighted, Vector}} <: GraphProblem
3-
MaximalIS(graph; weights=UnWeighted(), openvertices=(),
2+
MaximalIS{CT<:AbstractEinsum,WT<:Union{NoWeight, Vector}} <: GraphProblem
3+
MaximalIS(graph; weights=NoWeight(), openvertices=(),
44
optimizer=GreedyMethod(), simplifier=nothing)
55
66
The [maximal independent set](https://psychic-meme-f4d866f8.pages.github.io/dev/tutorials/MaximalIS.html) problem. In the constructor, `weights` are the weights of vertices.
77
`optimizer` and `simplifier` are for tensor network optimization, check [`optimize_code`](@ref) for details.
88
"""
9-
struct MaximalIS{CT<:AbstractEinsum,WT<:Union{UnWeighted, Vector}} <: GraphProblem
9+
struct MaximalIS{CT<:AbstractEinsum,WT<:Union{NoWeight, Vector}} <: GraphProblem
1010
code::CT
1111
weights::WT
1212
end
1313

14-
function MaximalIS(g::SimpleGraph; weights=UnWeighted(), openvertices=(), optimizer=GreedyMethod(), simplifier=nothing)
15-
@assert weights isa UnWeighted || length(weights) == nv(g)
14+
function MaximalIS(g::SimpleGraph; weights=NoWeight(), openvertices=(), optimizer=GreedyMethod(), simplifier=nothing)
15+
@assert weights isa NoWeight || length(weights) == nv(g)
1616
rawcode = EinCode(([[Graphs.neighbors(g, v)..., v] for v in Graphs.vertices(g)]...,), collect(Int, openvertices))
1717
MaximalIS(_optimize_code(rawcode, uniformsize(rawcode, 2), optimizer, simplifier), weights)
1818
end

src/networks/Satisfiability.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ macro bools(syms::Symbol...)
104104
end
105105

106106
"""
107-
Satisfiability{CT<:AbstractEinsum,WT<:Union{UnWeighted, Vector}} <: GraphProblem
107+
Satisfiability{CT<:AbstractEinsum,WT<:Union{NoWeight, Vector}} <: GraphProblem
108108
Satisfiability(cnf::CNF; openvertices=(),
109109
optimizer=GreedyMethod(), simplifier=nothing)
110110

src/networks/networks.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ The abstract base type of graph problems.
55
"""
66
abstract type GraphProblem end
77

8-
struct UnWeighted end
9-
Base.getindex(::UnWeighted, i) = 1
10-
Base.eltype(::UnWeighted) = Int
8+
struct NoWeight end
9+
Base.getindex(::NoWeight, i) = 1
10+
Base.eltype(::NoWeight) = Int
1111

1212
######## Interfaces for graph problems ##########
1313
"""

test/configurations.jl

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

3333
@testset "enumerating" begin
3434
rawcode = IndependentSet(smallgraph(:petersen); optimizer=nothing)
35-
optcode = IndependentSet(optimize_code(rawcode.code, uniformsize(rawcode.code, 2), GreedyMethod()), 10, UnWeighted())
35+
optcode = IndependentSet(optimize_code(rawcode.code, uniformsize(rawcode.code, 2), GreedyMethod()), 10, NoWeight())
3636
for code in [rawcode, optcode]
3737
res0 = max_size(code)
3838
_, res1 = max_size_count(code)

0 commit comments

Comments
 (0)