You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/MaximalIS.jl
+12-8Lines changed: 12 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -9,12 +9,12 @@
9
9
# * how to compute weighted graphs and handle open vertices.
10
10
11
11
# ## Problem definition
12
-
using GraphTensorNetworks, Graphs, Compose
13
12
14
13
# In graph theory, a [maximal independent set](https://en.wikipedia.org/wiki/Maximal_independent_set) is an independent set that is not a subset of any other independent set.
15
14
# It is different from maximum independent set because it does not require the set to have the max size.
15
+
# In the following, we are going to solve the maximal independent set problem on the Petersen graph.
16
16
17
-
# In the following, we are going to solve the maximal independent set problem for the Petersen graph.
17
+
using GraphTensorNetworks, Graphs, Compose
18
18
19
19
graph = Graphs.smallgraph(:petersen)
20
20
@@ -26,8 +26,8 @@ locations = [[rot15(0.0, 1.0, i) for i=0:4]..., [rot15(0.0, 0.6, i) for i=0:4]..
26
26
show_graph(graph; locs=locations)
27
27
28
28
# ## Tensor network representation
29
-
#Type [`MaximalIS`](@ref) can be used for constructing the tensor network with optimized contraction order for solving a maximal independent set problem.
30
-
#For a vertex ``v\in V``, we define a boolean degree of freedom ``s_v\in\{0, 1\}``.
29
+
#Let ``G=(V,E)`` be the target graph that we want to solve.
30
+
#The tensor network representation map a vertex ``v\in V`` to a boolean degree of freedom ``s_v\in\{0, 1\}``.
31
31
# We defined the restriction on its neighbourhood ``N[v]``:
# Intuitively, it means if all the neighbourhood vertices are not in ``I_{m}``, i.e., ``s_1=s_2=\ldots=s_{|N(v)|}=0``, then ``v`` should be in ``I_{m}`` and contribute a factor ``x_{v}``,
39
39
# otherwise, if any of the neighbourhood vertices is in ``I_{m}``, then ``v`` cannot be in ``I_{m}``.
40
-
# We construct the tensor network for the maximal independent set problem as
41
-
problem =MaximalIS(graph);
40
+
# We can use [`MaximalIS`](@ref) to construct the tensor network for solving the maximal independent set problem as
41
+
problem =MaximalIS(graph; optimizer=TreeSA());
42
42
43
43
# Its contraction time space complexity of a [`MaximalIS`](@ref) instance is no longer determined by the tree-width of the original graph ``G``.
44
44
# It is often harder to contract this tensor network than to contract the one for regular independent set problem.
45
45
46
+
timespacereadwrite_complexity(problem)
47
+
48
+
# Results are `log2` values.
49
+
46
50
# ## Solving properties
47
51
48
52
# ### Counting properties
@@ -55,7 +59,7 @@ problem = MaximalIS(graph);
55
59
56
60
max_config =solve(problem, GraphPolynomial())[]
57
61
58
-
#Since it only counts the maximal independent sets, the first several coefficients are 0.
62
+
#One can see the first several coefficients are 0, because it only counts the maximal independent sets,
# This result should be consistent with that given by the [Bron Kerbosch algorithm](https://en.wikipedia.org/wiki/Bron%E2%80%93Kerbosch_algorithm) on the complement of Petersen graph.
73
77
cliques =maximal_cliques(complement(graph))
74
78
75
-
# For sparse graphs, the generic tensor network approach is usually much faster and memory efficient.
79
+
# For sparse graphs, the generic tensor network approach is usually much faster and memory efficient than the Bron Kerbosch algorithm.
0 commit comments