|
1 | 1 | """ |
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=(), |
4 | 4 | optimizer=GreedyMethod(), simplifier=nothing) |
5 | 5 |
|
6 | 6 | The [independent set problem](https://psychic-meme-f4d866f8.pages.github.io/dev/tutorials/IndependentSet.html) in graph theory. |
7 | 7 | In the constructor, `weights` are the weights of vertices. |
8 | 8 | `openvertices` specifies labels for the output tensor. |
9 | 9 | `optimizer` and `simplifier` are for tensor network optimization, check [`optimize_code`](@ref) for details. |
10 | 10 | """ |
11 | | -struct IndependentSet{CT<:AbstractEinsum,WT<:Union{UnWeighted, Vector}} <: GraphProblem |
| 11 | +struct IndependentSet{CT<:AbstractEinsum,WT<:Union{NoWeight, Vector}} <: GraphProblem |
12 | 12 | code::CT |
13 | 13 | nv::Int |
14 | 14 | weights::WT |
15 | 15 | end |
16 | 16 |
|
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) |
19 | 19 | rawcode = EinCode([[[i] for i in Graphs.vertices(g)]..., # labels for vertex tensors |
20 | 20 | [[minmax(e.src,e.dst)...] for e in Graphs.edges(g)]...], collect(Int, openvertices)) # labels for edge tensors |
21 | 21 | code = _optimize_code(rawcode, uniformsize(rawcode, 2), optimizer, simplifier) |
@@ -70,7 +70,7 @@ julia> res = best_solutions(gp; all=true)[] |
70 | 70 | (2, {10010, 00110, 01100})ₜ |
71 | 71 | ``` |
72 | 72 | """ |
73 | | -function set_packing(sets; weights=UnWeighted(), openvertices=(), optimizer=GreedyMethod(), simplifier=nothing) |
| 73 | +function set_packing(sets; weights=NoWeight(), openvertices=(), optimizer=GreedyMethod(), simplifier=nothing) |
74 | 74 | n = length(sets) |
75 | 75 | 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)) |
76 | 76 | IndependentSet(_optimize_code(code, uniformsize(code, 2), optimizer, simplifier), n, weights) |
|
0 commit comments