6 * $Date: 2012-07-06 11:39:38 +0200 (Fr, 06. Jul 2012) $
7 ***************************************************************/
10 * \brief Implementation in-/out-points management.
12 * \author Carsten Gutwenger
15 * This file is part of the Open Graph Drawing Framework (OGDF).
19 * See README.txt in the root directory of the OGDF installation for details.
22 * This program is free software; you can redistribute it and/or
23 * modify it under the terms of the GNU General Public License
24 * Version 2 or 3 as published by the Free Software Foundation;
25 * see the file LICENSE.txt included in the packaging of this file
29 * This program is distributed in the hope that it will be useful,
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 * GNU General Public License for more details.
35 * You should have received a copy of the GNU General Public
36 * License along with this program; if not, write to the Free
37 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
38 * Boston, MA 02110-1301, USA.
40 * \see http://www.gnu.org/copyleft/gpl.html
41 ***************************************************************/
50 ListConstIterator
<InOutPoint
> IOPoints::searchRealForward(
51 ListConstIterator
<InOutPoint
> it
) const
53 while (it
.valid() && marked((*it
).m_adj
))
59 ListConstIterator
<InOutPoint
> IOPoints::searchRealBackward(
60 ListConstIterator
<InOutPoint
> it
) const
62 while (it
.valid() && marked((*it
).m_adj
))
69 void IOPoints::restoreDeg1Nodes(PlanRep
&PG
, Stack
<PlanRep::Deg1RestoreInfo
> &S
)
73 PG
.restoreDeg1Nodes(S
,deg1s
);
75 ListConstIterator
<node
> it
;
76 for(it
= deg1s
.begin(); it
.valid(); ++it
) {
77 adjEntry adj
= (*it
)->firstAdj();
78 m_mark
[adj
] = m_mark
[adj
->twin()] = true;
83 adjEntry
IOPoints::switchBeginIn(node v
)
85 List
<InOutPoint
> &Lin
= m_in
[v
];
86 List
<InOutPoint
> &Lout
= m_out
[v
];
88 ListConstIterator
<InOutPoint
> it
;
91 while ((it
= Lin
.begin()).valid() && marked(adj
= (*it
).m_adj
))
92 m_pointOf
[adj
] = &(*Lout
.pushFront(Lin
.popFrontRet()));
94 return it
.valid() ? adj
: 0;
98 adjEntry
IOPoints::switchEndIn(node v
)
100 List
<InOutPoint
> &Lin
= m_in
[v
];
101 List
<InOutPoint
> &Lout
= m_out
[v
];
103 ListConstIterator
<InOutPoint
> it
;
106 while ((it
= Lin
.rbegin()).valid() && marked(adj
= (*it
).m_adj
))
107 m_pointOf
[adj
] = &(*Lout
.pushBack(Lin
.popBackRet()));
109 return it
.valid() ? adj
: 0;
113 void IOPoints::switchBeginOut(node v
)
115 List
<InOutPoint
> &Lin
= m_in
[v
];
116 List
<InOutPoint
> &Lout
= m_out
[v
];
118 adjEntry adj
= (*Lout
.begin()).m_adj
;
119 m_pointOf
[adj
] = &(*Lin
.pushFront(Lout
.popFrontRet()));
123 void IOPoints::switchEndOut(node v
)
125 List
<InOutPoint
> &Lin
= m_in
[v
];
126 List
<InOutPoint
> &Lout
= m_out
[v
];
128 adjEntry adj
= (*Lout
.rbegin()).m_adj
;
129 m_pointOf
[adj
] = &(*Lin
.pushBack(Lout
.popBackRet()));
133 void IOPoints::numDeg1(node v
, int &xl
, int &xr
,
134 bool doubleCount
) const
136 const List
<InOutPoint
> &L
= m_out
[v
];
137 ListConstIterator
<InOutPoint
> it
;
140 for (it
= L
.begin(); it
.valid() && marked((*it
).m_adj
); ++it
)
143 if (doubleCount
|| it
.valid()) // avoid double counting if all are marked
144 for (it
= L
.rbegin(); it
.valid() && marked((*it
).m_adj
); --it
)
148 InOutPoint
IOPoints::middleNeighbor(node z1
) const
150 const List
<InOutPoint
> &L
= m_in
[z1
];
152 ListConstIterator
<InOutPoint
> it
, itFound
;
153 int i
, pos
= (L
.size()-1)/2;
155 for (it
= L
.begin().succ(), i
= 1; i
<= pos
|| !itFound
.valid(); ++it
, ++i
)
156 if (!marked((*it
).m_adj
))
163 } // end namespace ogdf