5252
5353## Examples
5454
55- In this example, we will show how to compute the independent set properties of the Petersen graph, we first generate its tensor network contraction tree.
56- ``` julia
57- julia> using GraphTensorNetworks, Random, Graphs
58-
59- julia> graph = (Random. seed! (2 ); Graphs. smallgraph (:petersen ))
60- {10 , 15 } undirected simple Int64 graph
61-
62- julia> problem = IndependentSet (graph);
63- ```
64-
65- Here, the ` problem ` is a ` IndependentSet ` instance, it contains the tensor network contraction tree for the target graph (the ` code ` field).
66-
67- #### 1. find MIS size, count MISs and count ISs
68- * maximum independent set size
69- ``` julia
70- julia> solve (problem, SizeMax ())[]
71- 4.0 ₜ
72- ```
73- Here, the ` solve ` function returns you a 0-dimensional array.
74- For open graphs, this output tensor can have nonzero dimensionality. Each entry corresponds to a different boundary condition.
75-
76- * all independent sets
77- ``` julia
78- julia> solve (problem, CountingAll ())[]
79- 76.0
80- ```
81-
82- * counting maximum independent sets
83- ``` julia
84- julia> solve (problem, CountingMax ())[]
85- (4.0 , 5.0 )ₜ # first field is MIS size, second is its counting.
86- ```
87-
88- * counting independent sets of max two sizes with truncated polynomial
89- ``` julia
90- julia> solve (problem, CountingMax (2 ))[]
91- 0 - dimensional Array{Max2Poly{Float64, Float64}, 0 }:
92- 30.0 * x^ 3 + 5.0 * x^ 4
93- ```
94-
95- The following code computes independence polynomial using the finite field algebra (default) approach.
96- It is equivalent to counting independent sets of an arbituary size.
55+ You can find many examples in the documentation, a good one to start with is solving the independent set problem.
9756
98- ``` julia
99- julia> solve (problem, GraphPolynomial ())[]
100- Polynomial (1 + 10 * x + 30 * x^ 2 + 30 * x^ 3 + 5 * x^ 4 )
101- ```
102-
103- The program use ` finitefield ` method as the default approach, because it has no round off error is can be upload to GPU.
104-
105- #### 3. find/enumerate solutions
106- * find one of the best solutions,
107- ``` julia
108- julia> solve (problem, SingleConfigMax ())[]
109- (4.0 , ConfigSampler {10, 1, 1} (1010000011 ))ₜ
110- ```
111-
112- * enumerate all MISs
113- ``` julia
114- julia> cs = solve (problem, ConfigsMax ())[]
115- 0 - dimensional Array{CountingTropical{Int64, ConfigEnumerator{10 , 1 , 1 }}, 0 }:
116- (4 , {1010000011 , 0100100110 , 1001001100 , 0010111000 , 0101010001 })ₜ
117- ```
118- It will use the bounded version to save the computational effort. If you want to save/load your configurations, you can type
119- ``` julia
120- julia> save_configs (" configs.dat" , cs. c; format= :text ) # `:text` or `:binary`
121-
122- julia> load_configs (" configs.dat" ; format= :text )
123- {1010000011 , 0100100110 , 1001001100 , 0010111000 , 0101010001 }
124- ```
125-
126- * enumerate all configurations of size α(G) and α(G)-1
127- ``` julia
128- julia> solve (problem, ConfigsMax (2 ))[]
129- {0010101000 , 0101000001 , 0100100010 , 0010100010 , 0100000011 , 0010000011 , 1001001000 , 1010001000 , 1001000001 , 1010000001 , 1010000010 , 1000000011 , 0100100100 , 0000101100 , 0101000100 , 0001001100 , 0000100110 , 0100000110 , 1001000100 , 1000001100 , 1000000110 , 0100110000 , 0000111000 , 0101010000 , 0001011000 , 0010110000 , 0010011000 , 0001010001 , 0100010001 , 0010010001 }* x^ 3 + {1010000011 , 0100100110 , 1001001100 , 0010111000 , 0101010001 }* x^ 4
130- ```
131-
132- * enumerate all independent sets
133- ``` julia
134- julia> solve (problem, ConfigsAll ())[]
135- {0000000000 , 0000010000 , 1000000000 , 0001000000 , 0001010000 , 1001000000 , 0010000000 , 0010010000 , 1010000000 , 0000001000 , 0000011000 , 1000001000 , 0001001000 , 0001011000 , 1001001000 , 0010001000 , 0010011000 , 1010001000 , 0000000010 , 1000000010 , 0010000010 , 1010000010 , 0100000000 , 0100010000 , 0101000000 , 0101010000 , 0100000010 , 0000000100 , 1000000100 , 0001000100 , 1001000100 , 0000001100 , 1000001100 , 0001001100 , 1001001100 , 0000000110 , 1000000110 , 0100000100 , 0101000100 , 0100000110 , 0000100000 , 0000110000 , 0010100000 , 0010110000 , 0000101000 , 0000111000 , 0010101000 , 0010111000 , 0000100010 , 0010100010 , 0100100000 , 0100110000 , 0100100010 , 0000100100 , 0000101100 , 0000100110 , 0100100100 , 0100100110 , 0000000001 , 0000010001 , 1000000001 , 0001000001 , 0001010001 , 1001000001 , 0010000001 , 0010010001 , 1010000001 , 0000000011 , 1000000011 , 0010000011 , 1010000011 , 0100000001 , 0100010001 , 0101000001 , 0101010001 , 0100000011 }
136- ```
57+ https://psychic-meme-f4d866f8.pages.github.io/dev/tutorials/IndependentSet/
13758
13859## Supporting and Citing
13960
@@ -148,4 +69,4 @@ activities, we would be grateful if you could cite our work. The
14869You can
14970* Post a question on [ Julia Discourse forum] ( https://discourse.julialang.org/ ) , pin the package maintainer wih ` @1115 ` .
15071* Discuss in the ` #graphs ` channel of the [ Julia Slack] ( https://julialang.org/community/ ) , ping the package maintainer with ` @JinGuo Liu ` .
151- * Open an [ issue] ( https://github.com/Happy-Diode/GraphTensorNetworks.jl/issues ) if you encounter any problems, or have any feature request.
72+ * Open an [ issue] ( https://github.com/Happy-Diode/GraphTensorNetworks.jl/issues ) if you encounter any problems, or have any feature request.
0 commit comments