Skip to content

Commit b1eca96

Browse files
committed
polish weighted
1 parent ad266ba commit b1eca96

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

examples/PaintShop.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# !!! note
44
# It is highly recommended to read the [Independent set problem](@ref) chapter before reading this one.
55

6-
# ## Problme Definition
6+
# ## Problem Definition
77
# The [binary paint shop problem](http://m-hikari.com/ams/ams-2012/ams-93-96-2012/popovAMS93-96-2012-2.pdf) is defined as follows:
88
# we are given a ``2m`` length sequence containing ``m`` cars, where each car appears twice.
99
# Each car need to be colored red in one occurrence, and blue in the other.

examples/saveload.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ save_sumproduct(filename, all_independent_sets_tree)
2828
loaded_sets_tree = load_sumproduct(filename)
2929

3030
# ## Loading solutions to python
31-
# The following python script loads and unpacks the solutions as an array from a `:binary` formatted file.
31+
# The following python script loads and unpacks the solutions as a numpy array from a `:binary` format file.
3232
# ```python
3333
# import numpy as np
3434
#

examples/weighted.jl

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ using GenericTensorNetworks, Graphs
55

66
graph = Graphs.smallgraph(:petersen)
77

8-
# The following code computes the weighted MIS problem.
8+
# The following code constructs a weighted MIS problem instance.
99
problem = IndependentSet(graph; weights=collect(1:10));
1010

11-
# `weights` is a key word argument that can be a vector for weighted graphs or a `NoWeight()` object for unweighted graphs. The maximum independent set can be found as follows.
11+
# Here, the `weights` keyword argument can be a vector for weighted graphs or `NoWeight()` for unweighted graphs.
12+
# Most solution space properties work for unweighted graphs also work for the weighted graphs.
13+
# For example, the maximum independent set can be found as follows.
1214

1315
max_config_weighted = solve(problem, SingleConfigMax())[]
1416

@@ -20,14 +22,17 @@ locations = [[rot15(0.0, 1.0, i) for i=0:4]..., [rot15(0.0, 0.6, i) for i=0:4]..
2022
show_graph(graph; locs=locations, vertex_colors=
2123
[iszero(max_config_weighted.c.data[i]) ? "white" : "red" for i=1:nv(graph)])
2224

23-
# For weighted MIS problem, a property that many people care about is the "energy spectrum", or the largest weights.
24-
# We just feed a positional argument in the [`SizeMax`](@ref) constructor as the number of largest weights.
25+
# The only solution space property that can not be defined for general real-weighted (not including integer-weighted) graphs is the [`GraphPolynomial`](@ref).
26+
27+
# For the weighted MIS problem, a useful solution space property is the "energy spectrum", i.e. the largest several configurations and their weights.
28+
# We can use the solution space property is [`SizeMax`](@ref)`(10)` to compute the largest 10 weights.
2529
spectrum = solve(problem, SizeMax(10))[]
2630

27-
# The return value has type [`ExtendedTropical`](@ref), which contains one field `orders`. The `orders` is a vector of [`Tropical`](@ref) numbers.
31+
# The return value has type [`ExtendedTropical`](@ref), which contains one field `orders`.
2832
spectrum.orders
2933

30-
# We can get weighted independent sets with maximum 5 sizes.
34+
# We can see the `order` is a vector of [`Tropical`](@ref) numbers.
35+
# Similarly, we can get weighted independent sets with maximum 5 sizes as follows.
3136
max5_configs = solve(problem, SingleConfigMax(5))[]
3237

3338
# The return value also has type [`ExtendedTropical`](@ref), but this time the element type of `orders` has been changed to [`CountingTropical`](@ref)`{Float64,`[`ConfigSampler`](@ref)`}`.

0 commit comments

Comments
 (0)