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: README.md
+74-2Lines changed: 74 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,16 +33,21 @@ For current master
33
33
pkg> add UnitDiskMapping#master
34
34
```
35
35
36
-
## Example
36
+
## Example 1: Unweighted mapping
37
+
#### Step 1: map a Petersen graph to a grid graph
37
38
```julia
38
39
julia>using Graphs, UnitDiskMapping
39
40
40
41
julia> g =smallgraph(:petersen)
41
42
{10, 15} undirected simple Int64 graph
42
43
44
+
# `Branching()` is an exact algorithm for finding an optimal vertex ordering
43
45
julia> res =map_graph(g, vertex_order=Branching());
44
46
45
-
julia> res.grid_graph
47
+
julia> res.mis_overhead
48
+
89
49
+
50
+
julia>println(res.grid_graph)
46
51
⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅
47
52
⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅
48
53
⋅⋅⋅⋅⋅⋅ ● ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ ● ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ ● ⋅⋅⋅⋅⋅⋅
@@ -72,7 +77,74 @@ julia> res.grid_graph
72
77
⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅
73
78
⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅
74
79
⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅
80
+
```
81
+
82
+
#### Step 2: solve the MIS problem on grid graph with any method you like
83
+
In the following, we show how to solve this maximal independent set problem on grid graph with the open source package [`GraphTensorNetworks`](https://github.com/Happy-Diode/GraphTensorNetworks.jl) and map the configurations back.
84
+
The generic tensor network approach for solving MIS works best for graphs with small tree width, it can solve this grid graph `G(V,E)` in sub-exponential time `t~2^{sqrt(|V|)}`.
85
+
86
+
```julia
87
+
julia>using GraphTensorNetworks
88
+
89
+
julia> gp =Independence(SimpleGraph(res.grid_graph); optimizer=TreeSA(ntrials=1, niters=10), simplifier=MergeGreedy());
75
90
91
+
julia> misconfig =solve(gp, "config max")[].c;
92
+
93
+
# create a grid mask as the solution, where occupied locations are marked as value 1.
94
+
julia> c =zeros(Int, size(res.grid_graph.content));
0 commit comments