Skip to content

Commit 0010552

Browse files
authored
fix testcov being slow (#14)
* forbit parallel * fix testcov slow * fix readme
1 parent b1e3785 commit 0010552

File tree

3 files changed

+82
-73
lines changed

3 files changed

+82
-73
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,5 @@ jobs:
5353
with:
5454
github-token: ${{ secrets.GITHUB_TOKEN }}
5555
flag-name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
56-
parallel: true
56+
parallel: false
5757
path-to-lcov: lcov.info
58-
59-
finish:
60-
name: Coveralls Finished
61-
needs: test
62-
runs-on: ubuntu-latest
63-
steps:
64-
- uses: coverallsapp/github-action@master
65-
with:
66-
github-token: ${{ secrets.GITHUB_TOKEN }}
67-
parallel-finished: true

README.md

Lines changed: 67 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -37,60 +37,72 @@ pkg> add UnitDiskMapping#master
3737
```julia
3838
julia> using Graphs, UnitDiskMapping
3939

40-
julia> g = smallgraph(:bull)
41-
{5, 5} undirected simple Int64 graph
40+
julia> g = smallgraph(:petersen)
41+
{10, 15} undirected simple Int64 graph
4242

43-
julia> eg = embed_graph(g, 3)
44-
● ○ ● ○ ● ○ ◆ ○ ● ○ ● ○ ◆ ○ ● ○ ● ○ ◉ ○ ● ○ ● ○ ◉
45-
○ ○ ○ ○
46-
● ● ● ●
47-
○ ○ ○ ○
48-
● ● ● ●
49-
○ ○ ○ ○
50-
● ○ ● ○ ● ○ ◆ ○ ● ○ ● ○ ◆ ○ ● ○ ● ○ ◉
51-
○ ○ ○
52-
● ● ●
53-
○ ○ ○
54-
● ● ●
55-
○ ○ ○
56-
● ○ ● ○ ● ○ ◉ ○ ● ○ ● ○ ◆
57-
○ ○
58-
● ●
59-
○ ○
60-
● ●
61-
○ ○
62-
● ○ ● ○ ● ○ ◉
63-
64-
65-
66-
67-
68-
43+
julia> res = map_graph(g, vertex_order=Branching());
6944

70-
julia> apply_gadgets!(copy(eg))
71-
● ○ ● ○ ● ○ ○ ● ○ ● ○ ○ ● ○ ● ○ ○ ○ ● ○ ●
72-
○ ○
73-
● ● ● ●
74-
○ ○ ○ ○
75-
● ○ ○ ●
76-
○ ○ ○ ○ ○ ○ ○ ○
77-
● ○ ○ ○ ● ○ ○ ○ ● ○ ● ○
78-
○ ○ ○
79-
● ● ●
80-
○ ○ ○
81-
● ● ●
82-
○ ○ ○
83-
● ○ ● ○ ○ ○ ● ○ ● ○
84-
○ ○ ○ ○
85-
● ●
86-
○ ○
87-
● ●
88-
○ ○
89-
● ○ ● ○
90-
91-
92-
93-
94-
95-
96-
```
45+
julia> res.grid_graph
46+
47+
48+
49+
● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●
50+
51+
52+
53+
● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●
54+
● ● ● ● ● ● ● ● ●
55+
56+
57+
● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●
58+
● ● ● ● ● ●
59+
60+
61+
● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●
62+
● ● ● ● ● ●
63+
64+
65+
● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●
66+
● ● ● ● ● ● ● ● ●
67+
68+
69+
● ● ● ● ● ● ● ● ●
70+
71+
72+
73+
74+
75+
76+
julia> w_res = map_graph(Weighted(), g, vertex_order=Branching());
77+
78+
julia> w_res.grid_graph
79+
80+
81+
82+
◯ ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●
83+
84+
85+
86+
● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●
87+
● ● ● ● ● ● ● ● ●
88+
89+
90+
● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●
91+
● ● ● ● ● ●
92+
93+
94+
● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●
95+
● ● ● ● ● ●
96+
97+
98+
● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●
99+
● ● ● ● ● ● ● ● ●
100+
101+
102+
● ● ● ● ● ● ● ● ●
103+
104+
105+
106+
107+
108+
```

src/mapping.jl

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -356,24 +356,31 @@ struct MappingResult{CT,WT}
356356
end
357357

358358
"""
359-
map_graph([mode,] g::SimpleGraph; ruleset=[...])
359+
map_graph([mode=Weighted(),] g::SimpleGraph; vertex_order=Greedy(), ruleset=[...])
360360
361-
Map a graph to a unit disk grid graph that being "equivalent" to the original graph,
362-
where the optional argument `mode` can be `Weighted()` or `UnWeighted`.
361+
Map a graph to a unit disk grid graph that being "equivalent" to the original graph.
363362
Here "equivalent" means a maximum independent set in the grid graph can be mapped back to
364363
a maximum independent set of the original graph in polynomial time.
365364
365+
366+
* `mode` is optional, it can be `Weighted()` (default) or `UnWeighted`.
367+
* `vertex_order` specifies the order finding algorithm for vertices.
368+
Different vertex orders have different path width, i.e. different depth of mapped grid graph.
369+
It can be a vector or one of the following inputs
370+
* `Greedy()` fast but not optimal.
371+
* `Branching()` slow but optimal.
372+
* `ruleset` specifies and extra set of optimization patterns (not the crossing patterns).
373+
366374
Returns a `MappingResult` instance.
367375
"""
368-
map_graph(g::SimpleGraph; ruleset=[RotatedGadget(DanglingLeg(), n) for n=0:3]) = map_graph(UnWeighted(), g; ruleset=ruleset)
369-
function map_graph(mode, g::SimpleGraph; ruleset=[RotatedGadget(DanglingLeg(), n) for n=0:3])
370-
ug = embed_graph(mode, g)
376+
map_graph(g::SimpleGraph; vertex_order=Greedy(), ruleset=[RotatedGadget(DanglingLeg(), n) for n=0:3]) = map_graph(UnWeighted(), g; ruleset=ruleset, vertex_order=vertex_order)
377+
function map_graph(mode, g::SimpleGraph; vertex_order=Greedy(), ruleset=[RotatedGadget(DanglingLeg(), n) for n=0:3])
378+
ug = embed_graph(mode, g; vertex_order=vertex_order)
371379
mis_overhead0 = mis_overhead_copylines(ug)
372380
ug, tape = apply_crossing_gadgets!(mode, ug)
373381
ug, tape2 = apply_simplifier_gadgets!(ug; ruleset=ruleset)
374382
mis_overhead1 = isempty(tape) ? 0 : sum(x->mis_overhead(x[1]), tape)
375383
mis_overhead2 = isempty(tape2) ? 0 : sum(x->mis_overhead(x[1]), tape2)
376-
@show mis_overhead0 , mis_overhead1 , mis_overhead2
377384
return MappingResult(ug, vcat(tape, tape2) , mis_overhead0 + mis_overhead1 + mis_overhead2)
378385
end
379386

0 commit comments

Comments
 (0)