Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

hierarchical-ranking.cpp
Go to the documentation of this file.
2 #include <ogdf/basic/GraphList.h>
3 #include <ogdf/basic/Graph.h>
8 #include <iostream>
9 #include <string>
10 
11 using namespace ogdf;
12 
13 int r[] = {
14  0, 1, 2, 3, 4, 5, 5, 6, 7, 8, 9, 9, 10, 10, 11, 12, 12,
15  13, 14, 14, 15, 16, 17, 18, 18, 19, 19, 20, 21, 22, 22,
16  22, 23, 23, 23, 23, 24, 25, 26, 27, 27, 27, 28, 29, 29,
17  29, 30, 30, 31, 31, 31, 32, 33, 33, 34, 34, 35, 35, 35,
18  35, 0, 1, 2, 3, 5, 6, 7, 8, 10, 11, 12, 14, 15, 16, 18,
19  19, 20, 21, 22, 23, 25, 27, 29, 30, 31, 32, 33, 34, 35, -1
20 };
21 
22 int main()
23 {
24  Graph G;
25  GraphAttributes GA(G,
32  if (!GraphIO::read(GA, G, "unix-history-time.gml", GraphIO::readGML)) {
33  std::cerr << "Could not load unix-history-time.gml" << std::endl;
34  return 1;
35  }
36 
37  NodeArray<int> rank(G);
38  int i = 0;
39  for(node v : G.nodes)
40  rank[v] = r[i++];
41 
42  SugiyamaLayout SL;
44  SL.arrangeCCs(false);
45 
47  ohl->layerDistance(30.0);
48  ohl->nodeDistance(25.0);
49  ohl->weightBalancing(0.7);
50  SL.setLayout(ohl);
51 
52  SL.call(GA, rank);
53  GraphIO::write(GA, "output-unix-history-hierarchical-ranking.gml", GraphIO::writeGML);
54  GraphIO::write(GA, "output-unix-history-hierarchical-ranking.svg", GraphIO::drawSVG);
55 
56  return 0;
57 }
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
ogdf::GraphAttributes
Stores additional attributes of a graph (like layout information).
Definition: GraphAttributes.h:72
GraphAttributes.h
Declaration of class GraphAttributes which extends a Graph by additional attributes.
Graph.h
Includes declaration of graph class.
MedianHeuristic.h
Declaration of class MedianHeuristic.
ogdf::GraphIO::write
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.
ogdf::MedianHeuristic
The median heuristic for 2-layer crossing minimization.
Definition: MedianHeuristic.h:48
ogdf::GraphAttributes::edgeStyle
static const long edgeStyle
Corresponds to edge attributes strokeColor(edge), strokeType(edge), and strokeWidth(edge).
Definition: GraphAttributes.h:149
ogdf::GraphAttributes::nodeStyle
static const long nodeStyle
Corresponds to node attributes strokeColor(node), strokeType(node), strokeWidth(node),...
Definition: GraphAttributes.h:153
ogdf::GraphIO::writeGML
static bool writeGML(const Graph &G, std::ostream &os)
Writes graph G in GML format to output stream os.
ogdf::GraphIO::drawSVG
static bool drawSVG(const GraphAttributes &A, std::ostream &os, const SVGSettings &settings)
main
int main()
Definition: hierarchical-ranking.cpp:22
ogdf::OptimalHierarchyLayout::layerDistance
double layerDistance() const
Returns the minimal allowed y-distance between layers.
Definition: OptimalHierarchyLayout.h:108
ogdf::GraphIO::readGML
static bool readGML(Graph &G, std::istream &is)
Reads graph G in GML format from input stream is.
ogdf::SugiyamaLayout::call
virtual void call(GraphAttributes &GA) override
Calls the layout algorithm for graph GA.
ogdf::SugiyamaLayout::setCrossMin
void setCrossMin(LayeredCrossMinModule *pCrossMin)
Sets the module option for the two-layer crossing minimization.
Definition: SugiyamaLayout.h:390
ogdf::OptimalHierarchyLayout::nodeDistance
double nodeDistance() const
Returns the minimal allowed x-distance between nodes on a layer.
Definition: OptimalHierarchyLayout.h:98
r
int r[]
Definition: hierarchical-ranking.cpp:13
ogdf::SugiyamaLayout::setLayout
void setLayout(HierarchyLayoutModule *pLayout)
Sets the module option for the computation of the final layout.
Definition: SugiyamaLayout.h:399
GraphList.h
Decralation of GraphElement and GraphList classes.
ogdf::GraphAttributes::nodeTemplate
static const long nodeTemplate
Corresponds to node attribute templateNode(node).
Definition: GraphAttributes.h:156
GraphIO.h
Declares class GraphIO which provides access to all graph read and write functionality.
ogdf::OptimalHierarchyLayout::weightBalancing
double weightBalancing() const
Returns the weight for balancing successors below a node; 0.0 means no balancing.
Definition: OptimalHierarchyLayout.h:138
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:658
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:869
ogdf::GraphAttributes::nodeLabel
static const long nodeLabel
Corresponds to node attribute label(node).
Definition: GraphAttributes.h:134
ogdf::SugiyamaLayout::arrangeCCs
bool arrangeCCs() const
Returns the current setting of option arrangeCCs.
Definition: SugiyamaLayout.h:297
ogdf::SugiyamaLayout
Sugiyama's layout algorithm.
Definition: SugiyamaLayout.h:168
ogdf::GraphAttributes::edgeGraphics
static const long edgeGraphics
Corresponds to edge attribute bends(edge).
Definition: GraphAttributes.h:122
ogdf::GraphIO::read
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.
OptimalHierarchyLayout.h
Declaration and implementation of the optimal third phase of the Sugiyama algorithm.
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:240
ogdf::GraphAttributes::nodeGraphics
static const long nodeGraphics
Corresponds to node attributes x(node), y(node), width(node), height(node), and shape(node).
Definition: GraphAttributes.h:119
SugiyamaLayout.h
Declaration of Sugiyama algorithm.
ogdf::OptimalHierarchyLayout
The LP-based hierarchy layout algorithm.
Definition: OptimalHierarchyLayout.h:78