Skip to content

Commit

Permalink
Merge pull request #64 from skieffer/feasible-expansions
Browse files Browse the repository at this point in the history
`libdialect:` Improve `Face::buildBestProjSeq()`
  • Loading branch information
skieffer authored Aug 5, 2023
2 parents a48c7bf + a1dd35a commit b00f07b
Show file tree
Hide file tree
Showing 4 changed files with 179 additions and 1 deletion.
9 changes: 9 additions & 0 deletions cola/libdialect/faces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,15 @@ ProjSeq_SP Face::buildBestProjSeq(TreePlacement_SP tp, double padding,
// Expand.
ExpansionManager em2(tp, dim, padding);
ProjSeq_SP ps1 = em2.extendProjSeq(ps0);
if (ps1 == nullptr) {
// First try failed. Try again, with the other dimension as primary.
ExpansionManager em3(tp, vpsc::conjugate(dim), padding);
m_graph->popNodePositions();
m_graph->pushNodePositions();
// Can reuse `ps0`, since `ExpansionGoal::tryExpansionRec()` works
// with a fresh copy of it, leaving it unaltered.
ps1 = em3.extendProjSeq(ps0);
}
// Restore node positions and return.
m_graph->popNodePositions();
return ps1;
Expand Down
3 changes: 2 additions & 1 deletion cola/libdialect/tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LDADD = \
$(top_builddir)/libdialect/libdialect.la

# Basic unit testing:
check_PROGRAMS = aca assignments bbox bendcosts chainconfig01 chainconfig02 chainconfig03 chainsandcycles cmplayout01 collateralexpand01 collateralexpand02 conncomps containedsegment01 destress destress02 destress_aca expand01 expand02 expand03 expand04 expand05 expand06 expand07 expand08 expand09 extrabdrygap faceset01 faceset02 hola10 hola11 hola12 hola_arpa hola_slovakia holalonenode inserttrees01 leaflessroute01 leaflessroute02 lookupqas nbroctal nearalign01 nearalign02 nearby negativesepco negativezero nodeconfig01 nudgeopt partition01 peel planarise01 planarise02 projseq01 readconstraints rotate01 rotate02 rotate03 rotate04 routing01 sep_matrix_iter solidify symmtree tglf01 treeboxes01 treeplacement01 treeplacement02 treeplacement03 trees trees2 vpsc01
check_PROGRAMS = aca assignments bbox bendcosts chainconfig01 chainconfig02 chainconfig03 chainsandcycles cmplayout01 collateralexpand01 collateralexpand02 conncomps containedsegment01 destress destress02 destress_aca expand01 expand02 expand03 expand04 expand05 expand06 expand07 expand08 expand09 extrabdrygap faceset01 faceset02 hola10 hola11 hola12 hola_arpa hola_garr hola_slovakia holalonenode inserttrees01 leaflessroute01 leaflessroute02 lookupqas nbroctal nearalign01 nearalign02 nearby negativesepco negativezero nodeconfig01 nudgeopt partition01 peel planarise01 planarise02 projseq01 readconstraints rotate01 rotate02 rotate03 rotate04 routing01 sep_matrix_iter solidify symmtree tglf01 treeboxes01 treeplacement01 treeplacement02 treeplacement03 trees trees2 vpsc01

# Test HOLA on some larger and more interesting SBGN and metro map diagrams:
# Takes a few minutes.
Expand Down Expand Up @@ -51,6 +51,7 @@ hola10_SOURCES = hola10.cpp
hola11_SOURCES = hola11.cpp
hola12_SOURCES = hola12.cpp
hola_arpa_SOURCES = hola_arpa.cpp
hola_garr_SOURCES = hola_garr.cpp
hola_slovakia_SOURCES = hola_slovakia.cpp
holalonenode_SOURCES = holalonenode.cpp
inserttrees01_SOURCES = inserttrees01.cpp
Expand Down
124 changes: 124 additions & 0 deletions cola/libdialect/tests/graphs/special/Garr201001.tglf
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
// Derived from http://www.topology-zoo.org/dataset.html
0 449.0 -831.0 46.0 34.0
1 299.0 -923.0 41.0 34.0
2 523.5 -1015.0 29.0 34.0
3 311.0 -729.0 41.0 34.0
4 543.0 -463.0 158.0 34.0
5 366.0 -923.0 56.0 34.0
6 222.0 -463.0 20.0 34.0
7 564.0 -1015.0 20.0 34.0
8 462.0 -565.0 68.0 34.0
9 342.0 -247.0 20.0 34.0
10 467.0 -21.0 22.0 34.0
11 371.0 -391.0 22.0 34.0
12 252.0 -565.0 128.0 34.0
13 669.0 -923.0 74.0 34.0
14 55.0 -729.0 30.0 34.0
15 180.0 -1015.0 32.0 34.0
16 465.0 -247.0 74.0 34.0
17 418.5 -83.0 23.0 34.0
18 467.0 -83.0 22.0 34.0
19 513.0 -165.0 122.0 34.0
20 125.0 -923.0 51.0 34.0
21 605.5 -637.0 21.0 34.0
22 215.0 -923.0 92.0 34.0
23 575.0 -831.0 41.0 34.0
24 630.0 -565.0 68.0 34.0
25 533.0 -565.0 43.0 34.0
26 528.0 -391.0 32.0 34.0
27 653.0 -637.0 22.0 34.0
28 582.0 -247.0 128.0 34.0
29 610.5 -165.0 23.0 34.0
30 515.5 -83.0 21.0 34.0
31 593.0 -83.0 98.0 34.0
32 635.0 -831.0 38.0 34.0
33 515.0 -831.0 33.0 34.0
34 423.0 -463.0 50.0 34.0
35 408.0 -391.0 20.0 34.0
36 12.0 -729.0 20.0 34.0
37 225.0 -637.0 74.0 34.0
38 285.0 -831.0 86.0 34.0
39 611.5 -1015.0 21.0 34.0
40 459.0 -729.0 218.0 34.0
41 396.0 -1015.0 44.0 34.0
42 522.0 -637.0 44.0 34.0
43 345.0 -637.0 50.0 34.0
44 377.5 -165.0 21.0 34.0
45 143.0 -247.0 22.0 34.0
46 425.0 -165.0 22.0 34.0
47 585.0 -329.0 26.0 34.0
48 537.0 -329.0 26.0 34.0
49 345.0 -329.0 38.0 34.0
50 191.0 -247.0 22.0 34.0
51 228.0 -247.0 20.0 34.0
52 216.0 -329.0 164.0 34.0
53 276.5 -247.0 21.0 34.0
#
0 40
1 38
2 13
3 43
4 8
4 12
4 16
4 24
4 25
4 26
4 28
4 40
4 47
5 15
5 38
5 40
5 41
6 12
7 13
8 34
8 42
8 43
9 49
10 18
11 34
12 34
12 37
12 38
12 49
12 52
13 38
13 39
13 40
14 37
15 37
16 19
16 44
16 46
16 52
17 19
18 19
19 28
19 30
19 31
20 38
21 24
22 38
23 40
24 27
24 28
26 48
28 29
28 47
28 48
28 49
32 40
33 40
34 35
36 37
37 38
38 40
40 41
40 42
40 43
45 52
50 52
51 52
52 53
44 changes: 44 additions & 0 deletions cola/libdialect/tests/hola_garr.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* vim: ts=4 sw=4 et tw=0 wm=0
*
* libdialect - A library for computing DiAlEcT layouts:
* D = Decompose/Distribute
* A = Arrange
* E = Expand/Emend
* T = Transform
*
* Copyright (C) 2018 Monash University
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* See the file LICENSE.LGPL distributed with the library.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* Author(s): Steve Kieffer <http://skieffer.info>
*/

#include "libdialect/commontypes.h"
#include "libdialect/io.h"
#include "libdialect/util.h"
#include "libdialect/graphs.h"
#include "libdialect/opts.h"
#include "libdialect/logging.h"
#include "libdialect/hola.h"

using namespace dialect;

int main(void) {
Graph_SP graph = buildGraphFromTglfFile("graphs/" "special/Garr201001.tglf");
HolaOpts opts;
std::string prefix = "hola_garr_";
bool debug = false;
if (debug) doHOLA(*graph, opts, new Logger("output/", prefix, true, true));
else doHOLA(*graph, opts);
writeStringToFile(graph->writeTglf(), "output/" + prefix + "layout.tglf");
writeStringToFile(graph->writeSvg(), "output/" "svg/" + prefix + "layout.svg");
}

0 comments on commit b00f07b

Please sign in to comment.