Skip to content

Commit 22b8731

Browse files
committed
update maximal idp
1 parent 51c1e03 commit 22b8731

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

examples/MaximalIS.jl

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
# * how to compute weighted graphs and handle open vertices.
1010

1111
# ## Problem definition
12-
using GraphTensorNetworks, Graphs, Compose
1312

1413
# 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.
1514
# 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.
1616

17-
# In the following, we are going to solve the maximal independent set problem for the Petersen graph.
17+
using GraphTensorNetworks, Graphs, Compose
1818

1919
graph = Graphs.smallgraph(:petersen)
2020

@@ -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]..
2626
show_graph(graph; locs=locations)
2727

2828
# ## 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\}``.
3131
# We defined the restriction on its neighbourhood ``N[v]``:
3232
# ```math
3333
# T(x_v)_{s_1,s_2,\ldots,s_{|N(v)|},s_v} = \begin{cases}
@@ -37,12 +37,16 @@ show_graph(graph; locs=locations)
3737
# ```
3838
# 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}``,
3939
# 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());
4242

4343
# Its contraction time space complexity of a [`MaximalIS`](@ref) instance is no longer determined by the tree-width of the original graph ``G``.
4444
# It is often harder to contract this tensor network than to contract the one for regular independent set problem.
4545

46+
timespacereadwrite_complexity(problem)
47+
48+
# Results are `log2` values.
49+
4650
# ## Solving properties
4751

4852
# ### Counting properties
@@ -55,7 +59,7 @@ problem = MaximalIS(graph);
5559

5660
max_config = solve(problem, GraphPolynomial())[]
5761

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,
5963

6064
# ### Configuration properties
6165
# ##### finding all maximal independent set
@@ -72,4 +76,4 @@ Compose.set_default_graphic_size(18cm, 12cm); Compose.compose(context(),
7276
# 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.
7377
cliques = maximal_cliques(complement(graph))
7478

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

Comments
 (0)