Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
hierarchical-ranking.cpp
Go to the documentation of this file.
5
6using namespace ogdf;
7
8int 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
17int main()
18{
19 Graph G;
20 GraphAttributes GA(G,
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
39 SL.arrangeCCs(false);
40
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.gml", GraphIO::writeGML);
49 GraphIO::write(GA, "output-unix-history-hierarchical-ranking.svg", GraphIO::drawSVG);
50
51 return 0;
52}
Declares class GraphIO which provides access to all graph read and write functionality.
Declaration of class MedianHeuristic.
Declaration and implementation of the optimal third phase of the Sugiyama algorithm.
Declaration of Sugiyama algorithm.
Stores additional attributes of a graph (like layout information).
static const long edgeStyle
Corresponds to edge attributes strokeColor(edge), strokeType(edge), and strokeWidth(edge).
static const long nodeLabel
Corresponds to node attribute label(node).
static const long nodeTemplate
Corresponds to node attribute templateNode(node).
static const long nodeStyle
Corresponds to node attributes strokeColor(node), strokeType(node), strokeWidth(node),...
static const long edgeGraphics
Corresponds to edge attribute bends(edge).
static const long nodeGraphics
Corresponds to node attributes x(node), y(node), width(node), height(node), and shape(node).
Data type for general directed graphs (adjacency list representation).
Definition Graph_d.h:521
static bool write(const Graph &G, const string &filename, WriterFunc writer=nullptr)
Writes graph G to a file with name filename and infers the format to use from the file's extension.
static bool writeGML(const Graph &G, std::ostream &os)
Writes graph G in GML format to output stream os.
static bool drawSVG(const GraphAttributes &A, std::ostream &os, const SVGSettings &settings)
static bool readGML(Graph &G, std::istream &is)
Reads graph G in GML format from input stream is.
static bool read(Graph &G, const string &filename, ReaderFunc reader=nullptr)
Reads graph G from a file with name filename and infers the used format from the file's extension.
The median heuristic for 2-layer crossing minimization.
Dynamic arrays indexed with nodes.
Definition NodeArray.h:125
Class for the representation of nodes.
Definition Graph_d.h:177
The LP-based hierarchy layout algorithm.
double layerDistance() const
Returns the minimal allowed y-distance between layers.
double weightBalancing() const
Returns the weight for balancing successors below a node; 0.0 means no balancing.
double nodeDistance() const
Returns the minimal allowed x-distance between nodes on a layer.
Sugiyama's layout algorithm.
void setLayout(HierarchyLayoutModule *pLayout)
Sets the module option for the computation of the final layout.
bool arrangeCCs() const
Returns the current setting of option arrangeCCs.
void setCrossMin(LayeredCrossMinModule *pCrossMin)
Sets the module option for the two-layer crossing minimization.
virtual void call(GraphAttributes &GA) override
Calls the layout algorithm for graph GA.
int r[]
int main()
The namespace for all OGDF objects.