Skip to content

Commit 790add5

Browse files
committed
update docs
1 parent e2cac8f commit 790add5

File tree

16 files changed

+118
-48
lines changed

16 files changed

+118
-48
lines changed

docs/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
44
GraphTensorNetworks = "0978c8c2-34f6-49c7-9826-ea2cc20dabd2"
55
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
66
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
7+
Polynomials = "f27b6e38-b328-58d1-80ce-0feddd5e7a45"

docs/make.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Pkg
22
using GraphTensorNetworks
3+
using GraphTensorNetworks: TropicalNumbers, Polynomials, Mods
34
using Documenter
45
using DocThemeIndigo
56
using Literate
@@ -18,7 +19,7 @@ indigo = DocThemeIndigo.install(GraphTensorNetworks)
1819
DocMeta.setdocmeta!(GraphTensorNetworks, :DocTestSetup, :(using GraphTensorNetworks); recursive=true)
1920

2021
makedocs(;
21-
modules=[GraphTensorNetworks],
22+
modules=[GraphTensorNetworks, TropicalNumbers, Polynomials, Mods],
2223
authors="Jinguo Liu",
2324
repo="https://github.com/Happy-Diode/GraphTensorNetworks.jl/blob/{commit}{path}#{line}",
2425
sitename="GraphTensorNetworks.jl",
@@ -37,6 +38,7 @@ makedocs(;
3738
"Method Selection Guide" => "methodselection.md",
3839
"References" => "ref.md",
3940
],
41+
doctest=false,
4042
)
4143

4244
deploydocs(;

docs/src/ref.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
1+
```@meta
2+
DocTestSetup = quote
3+
import TropicalNumbers, Mods, Polynomials
4+
end
5+
```
16
# References
27

38
```@autodocs
49
Modules = [GraphTensorNetworks]
10+
```
11+
12+
```@docs
13+
TropicalNumbers.Tropical
14+
```
15+
16+
```@docs
17+
TropicalNumbers.CountingTropical
18+
```
19+
20+
```@docs
21+
Mods.Mod
22+
```
23+
24+
```@docs
25+
Polynomials.Polynomial
526
```

examples/IndependentSet/main.jl

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
# # Independent set problem
22

33
# ## Problem definition
4-
# An independent set is defined in the monadic second order language as
5-
# ```math
6-
# \exists x_i,\ldots,x_M\left[\bigwedge_{i\neq j} (x_i\neq x_j \wedge \neg \textbf{adj}(x_i, x_j))\right]
7-
# ```
4+
5+
# Please check the docstring of [`Independence`](@ref).
86

97
# ## Solving properties
108

@@ -16,25 +14,22 @@ problem = Independence(graph; optimizer=TreeSA(sc_weight=1.0, ntrials=10,
1614
βs=0.01:0.1:15.0, niters=20, rw_weight=0.2));
1715

1816
# maximum independent set size
19-
maximum_independent_set_size = solve(problem, "size max")
17+
maximum_independent_set_size = solve(problem, SizeMax())
2018

2119
# all independent sets
22-
count_all_independent_sets = solve(problem, "counting sum")
23-
24-
# counting maximum independent sets
25-
count_maximum_independent_sets = solve(problem, "counting max")
20+
count_all_independent_sets = solve(problem, CountingAll())
2621

2722
# counting independent sets of max two sizes
28-
count_max2_independent_sets = solve(problem, "counting max2")
23+
count_max2_independent_sets = solve(problem, CountingMax(2))
2924

3025
# compute the independence polynomial
31-
independence_polynomial = solve(problem, "counting all (finitefield)")
26+
independence_polynomial = solve(problem, GraphPolynomial(; method=:finitefield))
3227

3328
# find one MIS
34-
max_config = solve(problem, "config max")
29+
max_config = solve(problem, SingleConfigMax(; bounded=false))
3530

3631
# enumerate all MISs
37-
all_max_configs = solve(problem, "configs max (bounded)")
32+
all_max_configs = solve(problem, ConfigsMax(; bounded=true))
3833

3934
# enumerate all IS configurations
40-
all_independent_sets = solve(problem, "configs all")
35+
all_independent_sets = solve(problem, ConfigsAll())

src/GraphTensorNetworks.jl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,39 @@ using OMEinsum
77
using OMEinsum: timespace_complexity, getixsv
88
using Graphs
99

10+
# OMEinsum
1011
export timespace_complexity, @ein_str
1112
export GreedyMethod, TreeSA, SABipartite, KaHyParBipartite, MergeVectors, MergeGreedy
1213

14+
# Algebras
15+
export StaticBitVector, StaticElementVector, @bv_str
16+
export is_commutative_semiring
17+
export Max2Poly, TruncatedPoly, Polynomial, Tropical, CountingTropical, StaticElementVector, Mod, ConfigEnumerator, onehotv, ConfigSampler
18+
19+
# Lower level APIs
20+
export AllConfigs, SingleConfig
21+
export best_solutions, best2_solutions, solutions, all_solutions
22+
export bestk_solutions
23+
export contractx, contractf, graph_polynomial, max_size, max_size_count
24+
25+
# Graphs
26+
export random_regular_graph, diagonal_coupled_graph, isindependentset
27+
export square_lattice_graph, unitdisk_graph
28+
29+
# Tensor Networks (Graph problems)
30+
export Independence, MaximalIndependence, Matching, Coloring, optimize_code, set_packing, MaxCut, PaintShop, paintshop_from_pairs, UnWeighted
31+
32+
# Interfaces
33+
export solve, SizeMax, CountingAll, CountingMax, GraphPolynomial, SingleConfigMax, ConfigsAll, ConfigsMax
34+
35+
# Utilities
36+
export is_independent_set
37+
export mis_compactify!
38+
export save_configs, load_configs
39+
40+
# Visualization
41+
export vizeinsum, vizconfig
42+
1343
project_relative_path(xs...) = normpath(joinpath(dirname(dirname(pathof(@__MODULE__))), xs...))
1444

1545
include("utils.jl")

src/arithematics.jl

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
export is_commutative_semiring
2-
export Max2Poly, TruncatedPoly, Polynomial, Tropical, CountingTropical, StaticElementVector, Mod, ConfigEnumerator, onehotv, ConfigSampler
3-
export set_type, sampler_type
4-
51
using Polynomials: Polynomial
62
using TropicalNumbers: Tropical, CountingTropical
73
using Mods, Primes
@@ -60,7 +56,16 @@ function is_commutative_semiring(a::T, b::T, c::T) where T
6056
return true
6157
end
6258

63-
# get maximum two countings (polynomial truncated to largest two orders)
59+
"""
60+
TruncatedPoly{K,T,TO} <: Number
61+
62+
Polynomial truncated to largest `K` orders. `T` is the coefficients type and `TO` is the orders type.
63+
64+
```jldoctest; setup=(using GraphTensorNetworks)
65+
julia> TruncatedPoly((1,2,3), 6)
66+
x^4 + 2*x^5 + 3*x^6
67+
```
68+
"""
6469
struct TruncatedPoly{K,T,TO} <: Number
6570
coeffs::NTuple{K,T}
6671
maxorder::TO
@@ -125,6 +130,24 @@ end
125130
Base.:*(a::Bool, y::TruncatedPoly{K,T,TO}) where {K,T,TO} = a ? y : zero(y)
126131
Base.:*(y::TruncatedPoly{K,T,TO}, a::Bool) where {K,T,TO} = a ? y : zero(y)
127132

133+
"""
134+
ConfigEnumerator{N,S,C}
135+
136+
Set algebra for enumerating configurations, where `N` is the length of configurations,
137+
`C` is the size of storage in unit of `UInt64`,
138+
`S` is the bit width to store a single element in a configuration, i.e. `log2(# of flavors)`, for bitstrings, it is `1``.
139+
140+
```jldoctest; setup=:(using GraphTensorNetworks)
141+
julia> a = ConfigEnumerator([StaticBitVector([1,1,1,0,0]), StaticBitVector([1,0,0,0,1])])
142+
{11100, 10001}
143+
144+
julia> b = ConfigEnumerator([StaticBitVector([0,0,0,0,0]), StaticBitVector([1,0,1,0,1])])
145+
{00000, 10101}
146+
147+
julia> a + b
148+
{11100, 10001, 00000, 10101}
149+
```
150+
"""
128151
struct ConfigEnumerator{N,S,C}
129152
data::Vector{StaticElementVector{N,S,C}}
130153
end
@@ -158,6 +181,18 @@ Base.show(io::IO, x::ConfigEnumerator) = print(io, "{", join(x.data, ", "), "}")
158181
Base.show(io::IO, ::MIME"text/plain", x::ConfigEnumerator) = Base.show(io, x)
159182

160183
# the algebra sampling one of the configurations
184+
"""
185+
ConfigSampler{N,S,C}
186+
187+
The algebra for sampling one configuration, where `N` is the length of configurations,
188+
`C` is the size of storage in unit of `UInt64`,
189+
`S` is the bit width to store a single element in a configuration, i.e. `log2(# of flavors)`, for bitstrings, it is `1``.
190+
191+
```jldoctest; setup=:(using GraphTensorNetworks)
192+
julia> ConfigSampler(StaticBitVector([1,1,1,0,0]))
193+
ConfigSampler{5, 1, 1}(11100)
194+
```
195+
"""
161196
struct ConfigSampler{N,S,C}
162197
data::StaticElementVector{N,S,C}
163198
end

src/bitvector.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
export StaticBitVector, StaticElementVector, @bv_str
2-
31
"""
42
StaticElementVector{N,S,C}
53

src/bounding.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
using OMEinsum: DynamicEinCode
22

3-
export AllConfigs, SingleConfig
4-
53
struct AllConfigs{K} end
64
largest_k(::AllConfigs{K}) where K = K
75
struct SingleConfig end

src/configurations.jl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
export best_solutions, best2_solutions, solutions, all_solutions
2-
export bestk_solutions
3-
41
"""
52
best_solutions(problem; all=false, usecuda=false)
63

src/graph_polynomials.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ using OMEinsum: NestedEinsum, getixs, getiy
33
using FFTW
44
using Graphs
55

6-
export contractx, contractf, graph_polynomial, max_size, max_size_count
7-
86
"""
97
graph_polynomial(problem, method; usecuda=false, kwargs...)
108

0 commit comments

Comments
 (0)