1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319
|
/*
* $Revision: 4000 $
*
* last checkin:
* $Author: beyer $
* $Date: 2014-03-28 20:18:18 +0100 (Fri, 28 Mar 2014) $
***************************************************************/
/** \file
* \brief Layout algorithms for hypergraph based on edge standard
* representations (clique / star / tree) - HypergraphLayoutES
* and subset standard representation - HypergraphLayoutSS.
*
* ... edge standard is based partly on Section 7.2 of PhD Thesis
* by Dr. Chimani, subset standard is based on the following paper:
*
* Bertault, François and Eades, Peter.:Drawing Hypergraphs in the
* Subset Standard (Short Demo Paper) Graph Drawing Springer Berlin /
* Heidelberg 2001. pp.45-76. ISBN 978-3-540-41554-1
*
* \author Ondrej Moris
*
* \par License:
* This file is part of the Open Graph Drawing Framework (OGDF).
*
* \par
* Copyright (C)<br>
* See README.txt in the root directory of the OGDF installation for details.
*
* \par
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* Version 2 or 3 as published by the Free Software Foundation;
* see the file LICENSE.txt included in the packaging of this file
* for details.
*
* \par
* This program 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. See the
* GNU General Public License for more details.
*
* \par
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
* \see http://www.gnu.org/copyleft/gpl.html
***************************************************************/
#ifdef _MSC_VER
#pragma once
#endif
#ifndef OGDF_HYPERGRAPH_LAYOUT_H
#define OGDF_HYPERGRAPH_LAYOUT_H
#include <ogdf/hypergraph/Hypergraph.h>
#include <ogdf/hypergraph/EdgeStandardRep.h>
#include <ogdf/hypergraph/HypergraphAttributes.h>
#include <ogdf/hypergraph/HypergraphLayoutModule.h>
#include <ogdf/basic/exceptions.h>
#include <ogdf/basic/ModuleOption.h>
#include <ogdf/module/EmbedderModule.h>
#include <ogdf/module/CrossingMinimizationModule.h>
#include <ogdf/module/LayoutPlanRepModule.h>
#include <ogdf/planarity/PlanRep.h>
namespace ogdf {
class OGDF_EXPORT HypergraphLayoutSS : public HypergraphLayoutModule {
public:
enum Method {
dummyNode = 0x000001,
spanningTree = 0x000002,
steinerTree = 0x000003
};
private:
//!< Determines whether polygons should be convex (if possible).
bool m_convex;
//!< Defines the minimum distance between polygons and hypernodes.
int m_separation;
//!< Defines the number of algorithm iterations.
int m_iterations;
//!< Defines what method is used to represent hyperedges.
/**
* The following representation methods are available:
*
* 1. Dummy - star based representation of hyperedges such that
* all newly introduced dummy nodes are placed in the
* barycenter of their relevant hypernodes.
*
* 2. Spanning Tree - each hyperedge is represented by a minumum
* euclidean spanning tree of their hypenodes, no new
* dummy nodes are created.
*
* 3. Steiner Tree - each hyperedge is represented by a Steiner
* tree such that its leaves are hypernodes incident
* with the hyperedge, steiner vertices are represented
* by newly created nodes.
*/
Method representationHelper;
public:
//! Creates an instance of subset standard hypergraph layout.
HypergraphLayoutSS();
//! Copy constructor.
HypergraphLayoutSS(const HypergraphLayoutSS &hl);
//! Destructor.
~HypergraphLayoutSS();
//! Assignment operator.
HypergraphLayoutSS &operator=(const HypergraphLayoutSS &hl);
/**
* \brief Calls subset standard hypergraph layout.
*
* @param HA is the input hypergraph and will also be assigned the
* layout information.
*/
void call(HypergraphAttributes &HA)
{
layout(HA);
}
private:
/**
* Let a hypergraph H be given. The algorithm works as follows:
*
* 1. Hypernodes as assigned random positions (eg. on a grid).
*
* 2. Iterate the following (m_iterations):
*
* a) Transform H into a simple graph H based on a chosen
* representation method (dummy, spanning tree or steiner trees).
* Make sure hypernodes positions in G are preserved. See below
* for more details about representation methods.
* b) Apply any energy-based layout algorithm to get a layout of G.
* c) Set positions of hypernodes of H according to positions of their
* corresponding nodes of G.
*
* 3. Again, transform H into a simple graph H based on a chosen
* representation method preserving all hypernodes positions.
*
* 4. For each hyperedge e, draw a countour around edges of G representing
* e, make sure m_separation is kept between a contour and edges.
*
* 5. We say that a convex polygon representing a hyperedge e is valid
* when it does contain hypernodes incident with e only. If it m_convex
* is set then transform all contours into convex polygons unless they
* are valid (i.e. compute their convex hulls).
*
*/
void layout(HypergraphAttributes &HA)
{
OGDF_THROW_PARAM(LibraryNotSupportedException, lnscFunctionNotImplemented);
}
};
class OGDF_EXPORT HypergraphLayoutES : public HypergraphLayoutModule {
public:
//!< Final appearance is driven by given profile.
enum Profile {
Normal = 0x000001,
ElectricCircuit = 0x000002
};
private:
//!< The ration between width and height of a drawing.
double m_ratio;
//!< The number of crossings in the layout.
int m_crossings;
//!< Defines whether a drawing IO constraint is desired or not.
bool m_constraintIO;
//!< Defines whether inputs and outputs are placed on different "sides".
// TODO: This might require some tweaks in Hypergraph class.
bool m_constraintPorts;
//!< Defines the profile of the layout (eg. Electric Circuit).
Profile m_profile;
//!< The module for computing the final layout.
ModuleOption<LayoutPlanRepModule> m_planarLayoutModule;
//!< The module for crossing minimization.
ModuleOption<CrossingMinimizationModule> m_crossingMinimizationModule;
//!< The module for embedding planarization.
ModuleOption<EmbedderModule> m_embeddingModule;
public:
// constructor
HypergraphLayoutES();
// destructor
virtual ~HypergraphLayoutES() { }
// Dynamic casting is currently not working as desired and hence we left
// the following call inherited from superclass empty.
virtual void call(HypergraphAttributes &HA);
//void call(HypergraphAttributesES &HA);
//! Assignment operator.
HypergraphLayoutES &operator=(const HypergraphLayoutES &hl);
//! Returns the number of crossings in computed layout.
int crossings() const
{
return m_crossings;
}
//! Returns the ratio between width and height of a drawing.
double ratio() const
{
return m_ratio;
}
//! Sets the Input / Output drawing requirement.
void setConstraintIO(bool pConstraintIO)
{
m_constraintIO = pConstraintIO;
}
//! Sets the layout profile.
void setProfile(Profile pProfile)
{
m_profile = pProfile;
}
/** @}
* @name Modules
* @{
*/
/**
* \brief Sets the module option for the planar layout.
*
* Crossing minimization produces a planar representation of a hypergraph
* such that all crossings are replaced by additional dummy nodes.
* This is in fact a planar graph and hence it can be drawn quite
* easily by any planar layout algorithm.
*/
void setPlanarLayoutModule
(LayoutPlanRepModule *pPlanarLayoutModule)
{
m_planarLayoutModule.set(pPlanarLayoutModule);
}
/**
* \brief Sets the module option for crossing minimization.
*
* The crossing minimization module minimizes the crossings of a hypergraph
* in an edge standard representation.
*/
void setCrossingMinimizationModule
(CrossingMinimizationModule *pCrossingMinimizationModule)
{
m_crossingMinimizationModule.set(pCrossingMinimizationModule);
}
/**
* \brief Sets the module option for embedding.
*
* When a planarized edge representation of a hypergraph in computed,
* we have to found a way how to embed it (ie. find faces).
*/
void setEmbeddingModule
(EmbedderModule *pEmbeddingModule)
{
m_embeddingModule.set(pEmbeddingModule);
}
private:
void layout(HypergraphAttributesES &pHA);
//void planarizeCC(PlanRep &ccPlanarRep, List<edge> &fixedShell);
void packAllCC(PlanRep &planarRep,
HypergraphAttributesES &pHA,
Array<DPoint> &bounding);
std::pair<node,node> * insertShell(GraphCopySimple &planarRep,
List<node> &src,
List<node> &tgt,
List<edge> &fixedShell);
void removeShell(PlanRep &planarRep, std::pair<node,node> &st);
void applyProfile(HypergraphAttributesES &HA);
};
} // end namespace ogdf
#endif // OGDF_HYPERGRAPH_LAYOUT_H
|