6 * $Date: 2012-07-02 20:59:27 +0200 (Mon, 02 Jul 2012) $
7 ***************************************************************/
10 * \brief Declaration of optimal ranking algorithm for Sugiyama
13 * \author Carsten Gutwenger
16 * This file is part of the Open Graph Drawing Framework (OGDF).
20 * See README.txt in the root directory of the OGDF installation for details.
23 * This program is free software; you can redistribute it and/or
24 * modify it under the terms of the GNU General Public License
25 * Version 2 or 3 as published by the Free Software Foundation;
26 * see the file LICENSE.txt included in the packaging of this file
30 * This program is distributed in the hope that it will be useful,
31 * but WITHOUT ANY WARRANTY; without even the implied warranty of
32 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 * GNU General Public License for more details.
36 * You should have received a copy of the GNU General Public
37 * License along with this program; if not, write to the Free
38 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
39 * Boston, MA 02110-1301, USA.
41 * \see http://www.gnu.org/copyleft/gpl.html
42 ***************************************************************/
49 #ifndef OGDF_OPTIMAL_RANKING_H
50 #define OGDF_OPTIMAL_RANKING_H
54 #include <ogdf/module/RankingModule.h>
55 #include <ogdf/module/AcyclicSubgraphModule.h>
56 #include <ogdf/basic/ModuleOption.h>
57 #include <ogdf/basic/NodeArray.h>
62 //! The optimal ranking algorithm.
64 * The class OptimalRanking implements the LP-based algorithm for computing
65 * a node ranking with minimal edge lengths, which can be used as first phase
68 * <H3>Optional parameters</H3>
69 * The following options affect the crossing minimization step
74 * <th><i>Option</i><th><i>Type</i><th><i>Default</i><th><i>Description</i>
76 * <td><i>separateMultiEdges</i><td>bool<td>true
77 * <td>If set to true, multi-edges will span at least two layers.
81 * <H3>%Module options</H3>
85 * <th><i>Option</i><th><i>Type</i><th><i>Default</i><th><i>Description</i>
87 * <td><i>subgraph</i><td>AcyclicSubgraphModule<td>DfsAcyclicSubgraph
88 * <td>The module for the computation of the acyclic subgraph.
92 class OGDF_EXPORT OptimalRanking
: public RankingModule
{
94 ModuleOption
<AcyclicSubgraphModule
> m_subgraph
; // option for acyclic sugraph
95 bool m_separateMultiEdges
;
98 //! Creates an instance of optimal ranking.
103 * @name Algorithm call
107 //! Computes a node ranking of \a G in \a rank.
108 void call(const Graph
&G
, NodeArray
<int> &rank
);
110 //! Computes a node ranking of \a G with given minimal edge length in \a rank.
112 * @param G is the input graph.
113 * @param length specifies the minimal length of each edge.
114 * @param rank is assigned the rank (layer) of each node.
116 void call(const Graph
&G
, const EdgeArray
<int> &length
, NodeArray
<int> &rank
);
118 //! Computes a cost-minimal node ranking of \a G for given edge costs and minimal edge lengths in \a rank.
120 * @param G is the input graph.
121 * @param length specifies the minimal length of each edge.
122 * @param cost specifies the cost of each edge.
123 * @param rank is assigned the rank (layer) of each node.
127 const EdgeArray
<int> &length
,
128 const EdgeArray
<int> &cost
,
129 NodeArray
<int> &rank
);
133 * @name Optional parameters
137 //! Returns the current setting of option separateMultiEdges.
139 * If set to true, multi-edges will span at least two layers. Since
140 * each such edge will have at least one dummy node, the edges will
141 * automaticall be separated in a Sugiyama drawing.
143 bool separateMultiEdges() const { return m_separateMultiEdges
; }
145 //! Sets the option separateMultiEdges to \a b.
146 void separateMultiEdges(bool b
) { m_separateMultiEdges
= b
; }
150 * @name Module options
154 //! Sets the module for the computation of the acyclic subgraph.
155 void setSubgraph(AcyclicSubgraphModule
*pSubgraph
) {
156 m_subgraph
.set(pSubgraph
);
162 //! Implements the algorithm call.
163 void doCall(const Graph
& G
,
164 NodeArray
<int> &rank
,
165 EdgeArray
<bool> &reversed
,
166 const EdgeArray
<int> &length
,
167 const EdgeArray
<int> &cost
);
171 } // end namespace ogdf