75 int costAssoc = 1,
bool align =
false);
113 template<
class ATYPE>
124 bool align =
false) :
129 m_length .init((
Graph&)*
this, sep);
130 m_extraOfs .init((
Graph&)*
this, 0);
135 m_centerPriority =
true;
136 m_genToMedian =
true;
149 return m_extraOfs[v];
165 void insertVertexSizeArcs(
175 void insertVertexSizeArcs(
183 void insertVisibilityArcs(
189 void insertVisibilityArcs(
196 void setMinimumSeparation(
const PlanRep &PG,
210 bool areMulti(
edge e1,
edge e2)
const;
229 os <<
"[" << interval.
m_low <<
"," << interval.
m_high <<
249 ATYPE d = (*m_pPos)[x] - (*m_pPos)[y];
255 return (*m_pSec)[x] - (*m_pSec)[y];
265 return to_string(m_length[e]);
268 void setBasicArcsZeroLength(
const PlanRep &PG);
320 m_vertexArcCost = c_vertexArcFactor*costGen;
321 if (m_centerPriority)
322 m_bungeeCost = c_bungeeFactor*costGen+1;
324 m_bungeeCost = c_bungeeFactor*4+1;
326 m_MedianArcCost = c_MedianFactor*m_vertexArcCost;
327 m_doubleBendCost = c_doubleBendFactor*m_vertexArcCost;
332 template<
class ATYPE>
334 template<
class ATYPE>
336 template<
class ATYPE>
339 template<
class ATYPE>
344 template<
class ATYPE>
363 }
while(adj != adjFirst);
371 int numIncoming = faceSize - 3;
372 int median = (numIncoming / 2) + 1;
388 for (
int i = 0; i < median; i++) {
394 setExtra(vCenter, vMin, 0);
400 m_length[helper] = 0;
407 m_cost[e1] = m_MedianArcCost;
412 m_cost[e2] = m_MedianArcCost;
419 template<
class ATYPE>
459 template<
class ATYPE>
472 const ATYPE overhang = rc.
overhang();
476 if (PG.
expandAdj(v) ==
nullptr)
continue;
480 resetGenMergerLengths(PG,PG.
expandAdj(v));
485 ATYPE size = sizeOrig[v];
490 ATYPE rcMin = overhang + rc(v,dirMin);
491 ATYPE rcMax = overhang + rc(v,dirMax);
499 setBoundaryCosts(cornerDir,cornerOppDir);
507 m_length[m_edgeToBasicArc[cornerMax->
faceCyclePred()]] = rcMax;
511 delEdge(m_edgeToBasicArc[cornerDir]);
516 m_length[m_edgeToBasicArc[cornerMin->
faceCyclePred()]] = rcMin;
520 delEdge(m_edgeToBasicArc[cornerOppDir]);
533 m_length[e] = rcMin + size + rcMax - 2*overhang;
534 m_cost [e] = 2*m_vertexArcCost;
539 ATYPE minHalf = size/2;
540 ATYPE maxHalf = size - minHalf;
541 ATYPE lenMin = rcMin + minHalf - overhang;
542 ATYPE lenMax = maxHalf + rcMax - overhang;
547 m_length[e1] = lenMin;
548 m_cost [e1] = m_vertexArcCost;
551 m_length[e2] = lenMax;
552 m_cost [e2] = m_vertexArcCost;
559 m_length[e1] = lenMin;
560 m_cost [e1] = m_vertexArcCost;
563 m_length[e2] = lenMax;
564 m_cost [e2] = m_vertexArcCost;
572 template<
class ATYPE>
579 if (arc ==
nullptr)
continue;
592 m_cost[arc] = m_doubleBendCost;
603 template<
class ATYPE>
611 setBasicArcsZeroLength(PG);
621 if (PG.
expandAdj(v) ==
nullptr)
continue;
625 resetGenMergerLengths(PG,PG.
expandAdj(v));
630 ATYPE size = sizeOrig[v];
646 m_length[m_edgeToBasicArc[adj]] = minDist.
delta(v,
m_arcDir,i);
679 ATYPE lenMin = size/2;
680 ATYPE lenMax = size - lenMin;
682 setExtra(vCenter, cornerDir->
theNode(), lenMin);
685 m_length[e1] = lenMin;
686 m_cost[e1] = m_vertexArcCost;
689 m_length[e2] = lenMax;
690 m_cost[e2] = m_vertexArcCost;
710 m_cost[eBungeeCenter] = m_bungeeCost;
711 m_length[eBungeeCenter] = 0;
717 m_cost[eBungeeOut] = m_bungeeCost;
718 m_length[eBungeeOut] = 0;
744 m_cost[eBungeeCenter] = m_bungeeCost;
745 m_length[eBungeeCenter] = 0;
751 m_cost[eBungeeOut] = m_bungeeCost;
752 m_length[eBungeeOut] = 0;
765 m_cost[e] = 2*m_vertexArcCost;
770 ATYPE lenMin = size/2;
771 ATYPE lenMax = size - lenMin;
780 m_length[e1] = lenMin;
781 m_cost [e1] = m_vertexArcCost;
784 m_length[e2] = lenMax;
785 m_cost [e2] = m_vertexArcCost;
793 setExtra(vCenter, cornerDir->
theNode(), lenMin);
796 m_length[e1] = lenMin;
797 m_cost[e1] = m_vertexArcCost;
800 m_length[e2] = lenMax;
801 m_cost[e2] = m_vertexArcCost;
818 m_cost[eBungeeCenter] = m_bungeeCost;
819 m_length[eBungeeCenter] = 0;
825 m_cost[eBungeeOut] = m_bungeeCost;
826 m_length[eBungeeOut] = 0;
833 m_length[e1] = lenMin;
834 m_cost [e1] = m_vertexArcCost;
837 m_length[e2] = lenMax;
838 m_cost [e2] = m_vertexArcCost;
847 setExtra(vCenter, cornerDir->
theNode(), lenMin);
850 m_length[e1] = lenMin;
851 m_cost[e1] = m_vertexArcCost;
854 m_length[e2] = lenMax;
855 m_cost[e2] = m_vertexArcCost;
871 m_cost[eBungeeCenter] = m_bungeeCost;
872 m_length[eBungeeCenter] = 0;
878 m_cost[eBungeeOut] = m_bungeeCost;
879 m_length[eBungeeOut] = 0;
885 setBoundaryCosts(cornerDir,cornerOppDir);
890 else writeGML(
"northvertexsizeinserted.gml");
897 template<
class ATYPE>
903 c +=
cost(e) * (pos[e->target()] - pos[e->source()]);
914 template<
class ATYPE>
917 if (sweepLine.
empty())
922 if((*it).m_high < (*it).m_low)
925 ATYPE x = (*it).m_low;
927 for(++it; it.
valid(); ++it) {
928 if((*it).m_high < (*it).m_low)
930 if ((*it).m_high > x)
939 template<
class ATYPE>
952 for(
int d = 0; d < 4; ++d) {
958 insertVisibilityArcs(PG,posDir,posOrthDir,minDist);
968 template<
class ATYPE>
1004 segPos[v] = posDir[*it];
1005 low[v] = high[v] = posOrthDir[*it];
1007 for(++it; it.
valid(); ++it) {
1008 ATYPE x = posOrthDir[*it];
1013 if (x > high[v]) high[v] = x;
1015 lowReal[v] = low[v];
1019 bool subtractSep =
true;
1020 if (nodeLow->
degree() == 2) {
1031 adj2 = adj2->twin()->faceCycleSucc()) ;
1032 if(posDir[adjFound->
theNode()] == posDir[adj2->twinNode()])
1033 subtractSep =
false;
1053 if(PG.
expandAdj(v) ==
nullptr)
continue;
1067 ATYPE delta = (isCaseA) ?
1068 min(abs(posOrthDir[adjPred->
theNode()] - posOrthDir[adjPred->
twinNode()]), m_sep) :
1069 min(abs(posOrthDir[adj->
theNode()] - posOrthDir[adj->
twinNode()]), m_sep);
1070 ATYPE boundary = (isCaseA) ?
1071 min(posOrthDir[adjPred->
theNode()], posOrthDir[adjPred->
twinNode()]) :
1082 low[s1] = lowReal[s1] - delta;
1083 low[s2] = lowReal[s2] - delta;
1093 low[s1] = lowReal[s1] - delta;
1094 low[s2] = lowReal[s2] - delta;
1110 if(lowReal[s] != low[s])
1112 if(low[s] >= boundary)
1116 low[s] += m_sep - delta;
1137 if(segPos[sNext] != segPos[s])
1140 low[sNext] = lowReal[sNext];
1145 adjTwin = adjCross->
twin();
1152 for (adj = (isCaseA) ? vi.
m_corner[
static_cast<int>(dirMax)]->faceCycleSucc() : vi.
m_corner[
static_cast<int>(dirMax)]->faceCycleSucc()->
faceCycleSucc();
1160 ATYPE delta = -posOrthDir[adj->
twinNode()] + posOrthDir[adj->
theNode()];
1163 ATYPE delta = (isCaseA) ?
1164 min(abs(posOrthDir[adj->
twinNode()] - posOrthDir[adj->
theNode()]), m_sep) :
1165 min(abs(posOrthDir[adjPred->
theNode()] - posOrthDir[adjPred->
twinNode()]), m_sep);
1166 ATYPE boundary = (isCaseA) ?
1179 low[s1] = lowReal[s1] - delta;
1180 low[s2] = lowReal[s2] - delta;
1188 low[s1] = lowReal[s1] - delta;
1189 low[s2] = lowReal[s2] - delta;
1205 if(lowReal[s] != low[s])
1207 if(low[s] >= boundary)
1211 low[s] += m_sep - delta;
1234 if(segPos[sNext] != segPos[s])
1237 low[sNext] = lowReal[sNext];
1242 adjTwin = adjCross->
twin();
1266 for(itV = sortedPathNodes.
begin(); itV.
valid(); ++itV)
1274 for(it = sweepLine.
begin(); it.
valid(); ++it) {
1275 if ((*it).m_low < high[v])
1284 if((*it).m_high <= low[v]) {
1292 bool isItUpDel = ( ((*itUp).m_low >= low[v]) && ((*itUp).m_high <= high[v]) );
1294 for(; it.
valid() && (*it).m_low >= low[v]; it = itSucc) {
1296 if ((*it).m_high <= high[v]) {
1302 if (it == itUp && (*it).m_high > high[v]) {
1303 node w = (*it).m_pathNode;
1305 (*it).m_low = high[v];
1310 if ( (!isItUpDel) && itUp != it && (*itUp).m_low < high[v]) {
1311 (*itUp).m_low = high[v];
1315 if ((*it).m_high > low[v]) {
1316 (*it).m_high = low[v];
1344 if (eOrig ==
nullptr)
continue;
1354 for(itT = visibArcs.
begin(); itT.
valid(); itT = itTSucc) {
1355 itTSucc = itT.
succ();
1356 node v = (*itT).x1(), w = (*itT).x2();
1359 if (correspEdge[v] && (correspEdge[v] == correspEdge[w]))
1361 if (itTPred.
valid())
1373 for(itT = visibArcs.
begin(); itT.
valid(); ++itT) {
1375 node v = (*itT).x1(), w = (*itT).x2();
1383 if (!( ( en1 && en2 ) && ( en1 == en2) ))
1389 m_length[e] = max(m_sep, minDist.
separation());
1393 writeGML(
"visibilityinserted.gml");
1405 template<
class ATYPE>
1412 if (pos[w] - pos[v] < length(e)) {
1413 std::cout <<
"feasibility check failed for edge " << e << std::endl;
1414 std::cout <<
" representatives: " << v <<
", " << w << std::endl;
1415 std::cout <<
" length: " << length(e) << std::endl;
1416 std::cout <<
" actual distance: " << pos[w] - pos[v] << std::endl;
1417 std::cout <<
" type of " << e <<
": ";
node target() const
Returns the target node of the edge.
int m_MedianArcCost
draw merger gen at median of incoming generalizations
int m_doubleBendCost
try to minimize double bends
void delSucc(iterator itBefore)
Removes the succesor of itBefore.
edge theEdge() const
Returns the edge associated with this adjacency entry.
bool valid() const
Returns true iff the iterator points to an element.
ListIteratorBase< E, isConst, isReverse > succ() const
Returns successor iterator.
void centerPriority(bool b)
Sets centerPriority (center single edges?)
void setBoundaryCosts(adjEntry cornerDir, adjEntry cornerOppDir)
void insertVertexSizeArcs(const PlanRep &PG, const NodeArray< ATYPE > &sizeOrig, const RoutingChannel< ATYPE > &rc)
Inserts arcs for respecting sizes of vertices and achieving desired placement of generalizations if v...
iterator pushBack(const E &x)
Adds element x at the end of the list.
Data type for general directed graphs (adjacency list representation).
int m_bungeeCost
middle position distance penalty
#define OGDF_AUGMENT_COMPARER(type)
Add this macro to your class to turn it into a full comparer.
NodeArray< node > m_pathNode
segment containing a node in PG
adjEntry adjSource() const
Returns the corresponding adjacancy entry at source node.
bool checkSweepLine(const List< Interval > &sweepLine) const
Maintains input sizes for improvement compaction (deltas and epsilons)
NodeArray< bool > m_extraNode
Node does not represent drawing node as we dont have positions we save a drawing representant and an ...
ATYPE extraOfs(node v) const
Returns extraNode position, change to save mem, only need some entries.
int totalAttached() const
Information about a side of a vertex in UML diagrams.
#define OGDF_THROW(CLASS)
Replacement for throw.
int degree() const
Returns the degree of the node (indegree + outdegree).
const Graph & getGraph() const
Returns underlying graph.
int angle(adjEntry adj) const
const ATYPE & epsilon(node v, OrthoDir s, int i) const
adjEntry faceCyclePred() const
Returns the cyclic predecessor in face.
iterator begin()
Returns an iterator to the first element of the list.
Represents a constraint graph used for compaction.
EdgeArray< bool > m_alignmentArc
Basic arcs that have to be short for alignment (node to gen expander)
iterator insertAfter(const E &x, iterator it)
Inserts element x after it.
Orthogonal representation of an embedded graph.
static const int c_bungeeFactor
virtual void delEdge(edge e)
Removes edge e from the graph.
Declaration of a base class for planar representations of graphs and cluster graphs.
Further information about the cages of vertices in UML diagrams.
NodeArray< edge > m_originalEdge
save edge for the basic arcs
Encapsulates a pointer to an ogdf::SList element.
SListIteratorBase< E, isConst > succ() const
Returns successor iterator.
#define OGDF_HEAVY_ASSERT(expr)
Assert condition expr when using heavy debugging. See OGDF_ASSERT.
adjEntry cyclicSucc() const
Returns the cyclic successor in the adjacency list.
Graph::NodeType typeOf(node v) const
Returns the type of node v.
Declaration of class RoutingChannel which maintains required size of routing channels and separation...
bool valid() const
Returns true iff the iterator points to an element.
CompactionConstraintGraphBase(const OrthoRep &OR, const PlanRep &PG, OrthoDir arcDir, int costGen=1, int costAssoc=1, bool align=false)
Construction.
void del(iterator it)
Removes it from the list.
adjEntry faceCycleSucc() const
Returns the cyclic successor in face.
bool m_centerPriority
should centering be more expensive than generalizations
const NodeArray< ATYPE > * m_pPos
NodeArray< edge > m_pathToEdge
save the (single!) edge (segment) for a pathNode
const NodeArray< int > * m_pSec
int m_vertexArcCost
get small cages
Represents an interval on the sweep line.
internal::GraphObjectContainer< EdgeElement > edges
The container containing all edge objects.
adjEntry expandAdj(node v) const
Returns the adjacency entry of a node of an expanded face.
Dynamic arrays indexed with nodes.
ATYPE separation() const
Returns the separation value.
iterator begin()
Returns an iterator to the first element of the list.
void removeRedundantVisibArcs(SListPure< Tuple2< node, node >> &visibArcs)
Removes "arcs" from visibArcs which we already have in the constraint graph (as basic arcs) ...
void quicksort()
Sorts the list using Quicksort.
bool m_genToMedian
draw outgoing generalization from merger above ingoing gen.
iterator pushBack(const E &x)
Adds element x at the end of the list.
NodeArray< node > m_extraRep
existing representant of extranodes position anchor
Tuples of two elements (2-tuples).
CompactionConstraintGraph(const OrthoRep &OR, const PlanRep &PG, OrthoDir arcDir, ATYPE sep, int costGen=1, int costAssoc=1, bool align=false)
Construction.
Doubly linked lists (maintaining the length of the list).
edge newEdge(node v, node w)
Creates a new edge (v,w) and returns it.
bool verticalArc(edge e) const
Returns true if e is basic arc of vertical edge in PlanRepUML hierarchy.
A common base class for ogdf::GridCompactionConstraintGraphBase and ogdf::CompactionConstraintGraphBa...
const VertexInfoUML * cageInfo(node v) const
Exception thrown when an algorithm realizes an internal bug that prevents it from continuing...
void setBasicArcsZeroLength(const PlanRep &PG)
static const int c_doubleBendFactor
double bends cost factor*vertexArcCost
node twinNode() const
Returns the associated node of the corresponding adjacency entry (shorthand for twin()->theNode()).
Class for the representation of edges.
adjEntry twin() const
Returns the corresponding adjacency element associated with the same edge.
EdgeArray< int > m_cost
cost of an edge
void popFront()
Removes the first element from the list.
void insertBasicArcs(const PlanRep &PG)
void resetGenMergerLengths(const PlanRep &PG, adjEntry adjFirst)
Maintains input sizes for constructive compaction (size of routing channels, separation, cOverhang)
Class for the representation of nodes.
Encapsulates a pointer to a list element.
node expandedNode(node v) const
SegmentComparer(const NodeArray< ATYPE > &segPos, const NodeArray< int > &secSort)
ATYPE length(edge e) const
Returns length of edge e.
void insertPathVertices(const PlanRep &PG)
virtual string getLengthString(edge e) const override
const Graph & original() const
Returns a reference to the original graph.
node m_pathNode
corresponding segment
adjEntry cyclicPred() const
Returns the cyclic predecessor in the adjacency list.
EdgeArray< ATYPE > m_length
length of an edge
int cost(edge e) const
Returns cost of edge e.
inserted to replace some reducible in fixzerolength
Comparer class used for sorting segments by increasing position (given by segPos) such that two overl...
static OrthoDir prevDir(OrthoDir d)
Returns the previous OrthoDir (in a clockwise manner)
ATYPE computeTotalCosts(const NodeArray< ATYPE > &pos) const
Computes the total costs for coordintes given by pos, i.e., the sum of the weighted lengths of edges ...
void computeTopologicalSegmentNum(NodeArray< int > &topNum)
Computes topological numbering on the segments of the constraint graph.
static OrthoDir nextDir(OrthoDir d)
Returns the next OrthoDir (in a clockwise manner)
bool isFeasible(const NodeArray< ATYPE > &pos)
Performs feasibility test for position assignment pos, i.e., checks if the segment positions given by...
void setExtra(node v, node rep, ATYPE ofs)
Node v has no representation in drawing, only internal representation.
static const int c_MedianFactor
median arcs cost factor*vertexArcCost
static const int c_vertexArcFactor
Declaration of class MinimumEdgeDistances which maintains minimum distances between attached edges at...
Interval(node v, ATYPE low, ATYPE high)
bool alignmentArc(edge e) const
Returns if arc is important for alignment. These are the arcs representing node to gen...
const ATYPE & delta(node v, OrthoDir s, int i) const
NodeArray< ATYPE > m_extraOfs
offset of extra node to its rep, should change this
int compare(const node &x, const node &y) const
can be compacted to zero length
void allNodes(CONTAINER &nodeContainer) const
Returns a container with all nodes of the graph.
can be compacted to zero length, can be fixed
void align(bool b)
Triggers alignment (=>some special edge handling to support al.)
OrthoDir direction(adjEntry adj) const
edge pathToOriginal(node v)
node source() const
Returns the source node of the edge.
NodeArray< SListPure< node > > m_path
list of nodes contained in a segment
iterator insertBefore(const E &x, iterator it)
Inserts element x before it.
Class implementing template-parameter-independent behaviour of ogdf::CompactionConstraintGraph.
The namespace for all OGDF objects.
void dfsInsertPathVertex(node v, node pathVertex, NodeArray< bool > &visited, const NodeArray< node > &genOpposite)
EdgeArray< bool > m_verticalGen
generalization that runs vertical relative to hierarchy
bool centerPriority()
Gets centerPriority (center single edges?)
NodeType
The type of nodes.
EdgeArray< ConstraintEdgeType > m_type
constraint type for each edge
EdgeArray< bool > m_verticalArc
arc corresponding to such an edge
node newNode()
Creates a new node and returns it.
internal::GraphObjectContainer< NodeElement > nodes
The container containing all node objects.
EdgeArray< edge > m_edgeToBasicArc
basic arc representing an edge in PG
void insertVisibilityArcs(const PlanRep &PG, const NodeArray< ATYPE > &posDir, const NodeArray< ATYPE > &posOppDir)
Inserts arcs connecting segments which can see each other in a drawing of the associated planarized r...
friend std::ostream & operator<<(std::ostream &os, const Interval &interval)
output operator
adjEntry adjTarget() const
Returns the corresponding adjacancy entry at target node.
ATYPE m_high
lower and upper bound
bool empty() const
Returns true iff the list is empty.
bool empty() const
Returns true iff the graph is empty, i.e., contains no nodes.
node theNode() const
Returns the node whose adjacency list contains this element.
bool verticalGen(edge e) const
Returns true if e is vertical edge in PlanRepUML hierarchy.
Class for adjacency list elements.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Declares ogdf::CommonCompactionConstraintGraphBase.
Planarized representations (of a connected component) of a graph.
internal::GraphObjectContainer< AdjElement > adjEntries
The container containing all entries in the adjacency list of this node.