1 | #include <ogdf/fileformats/GraphIO.h> |
2 | #include <ogdf/layered/MedianHeuristic.h> |
3 | #include <ogdf/layered/OptimalHierarchyLayout.h> |
4 | #include <ogdf/layered/SugiyamaLayout.h> |
5 | |
6 | using namespace ogdf; |
7 | |
8 | int r[] = { |
9 | 0, 1, 2, 3, 4, 5, 5, 6, 7, 8, 9, 9, 10, 10, 11, 12, 12, |
10 | 13, 14, 14, 15, 16, 17, 18, 18, 19, 19, 20, 21, 22, 22, |
11 | 22, 23, 23, 23, 23, 24, 25, 26, 27, 27, 27, 28, 29, 29, |
12 | 29, 30, 30, 31, 31, 31, 32, 33, 33, 34, 34, 35, 35, 35, |
13 | 35, 0, 1, 2, 3, 5, 6, 7, 8, 10, 11, 12, 14, 15, 16, 18, |
14 | 19, 20, 21, 22, 23, 25, 27, 29, 30, 31, 32, 33, 34, 35, -1 |
15 | }; |
16 | |
17 | int main() |
18 | { |
19 | Graph G; |
20 | GraphAttributes GA(G, |
21 | GraphAttributes::nodeGraphics | |
22 | GraphAttributes::edgeGraphics | |
23 | GraphAttributes::nodeLabel | |
24 | GraphAttributes::edgeStyle | |
25 | GraphAttributes::nodeStyle | |
26 | GraphAttributes::nodeTemplate); |
27 | if (!GraphIO::read(GA, G, "unix-history-time.gml" , GraphIO::readGML)) { |
28 | std::cerr << "Could not load unix-history-time.gml" << std::endl; |
29 | return 1; |
30 | } |
31 | |
32 | NodeArray<int> rank(G); |
33 | int i = 0; |
34 | for(node v : G.nodes) |
35 | rank[v] = r[i++]; |
36 | |
37 | SugiyamaLayout SL; |
38 | SL.setCrossMin(new MedianHeuristic); |
39 | SL.arrangeCCs(false); |
40 | |
41 | OptimalHierarchyLayout *ohl = new OptimalHierarchyLayout; |
42 | ohl->layerDistance(30.0); |
43 | ohl->nodeDistance(25.0); |
44 | ohl->weightBalancing(0.7); |
45 | SL.setLayout(ohl); |
46 | |
47 | SL.call(GA, rank); |
48 | GraphIO::write(GA, "output-unix-history-hierarchical-ranking.svg" , GraphIO::drawSVG); |
49 | |
50 | return 0; |
51 | } |
52 | |