6 * $Date: 2012-07-06 15:04:28 +0200 (Fr, 06. Jul 2012) $
7 ***************************************************************/
10 * \brief Implements class ExpansionGraph
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 ***************************************************************/
44 #include <ogdf/upward/ExpansionGraph.h>
45 #include <ogdf/basic/simple_graph_alg.h>
46 #include <ogdf/basic/NodeSet.h>
53 // computes biconnected componets of original graph
54 // does not create a copy graph
55 ExpansionGraph::ExpansionGraph(const Graph
&G
) :
56 m_compNum(G
), m_adjComponents(G
), m_vCopy(G
,0)
58 m_vOrig
.init(*this,0);
59 m_vRep
.init(*this,0);
60 m_eOrig
.init(*this,0);
62 // compute biconnected components
63 int numComp
= biconnectedComponents(G
,m_compNum
);
65 // for each component, build list of contained edges
66 m_component
.init(numComp
);
70 m_component
[m_compNum
[e
]].pushBack(e
);
72 // for each vertex v, build list of components containing v
73 NodeSetSimple
contained(G
);
74 for(int i
= 0; i
< numComp
; ++i
)
76 SListConstIterator
<edge
> it
;
77 for(it
= m_component
[i
].begin(); it
.valid(); ++it
)
81 if (contained
.isMember(v
) == false) {
83 m_adjComponents
[v
].pushBack(i
);
87 if (contained
.isMember(v
) == false) {
89 m_adjComponents
[v
].pushBack(i
);
98 // builds expansion graph of i-th biconnected component of the original graph
99 void ExpansionGraph::init(int i
)
101 OGDF_ASSERT(0 <= i
&& i
<= m_component
.high());
103 // remove previous component
105 forall_nodes(v
,*this) {
106 node vOrig
= m_vOrig
[v
];
113 // create new component
114 SListConstIterator
<edge
> it
;
115 for(it
= m_component
[i
].begin(); it
.valid(); ++it
)
119 edge eCopy
= newEdge(getCopy(e
->source()),getCopy(e
->target()));
124 forall_nodes(v
,*this)
126 if (original(v
) && v
->indeg() >= 1 && v
->outdeg() >= 1) {
127 node vPrime
= newNode();
128 m_vRep
[vPrime
] = m_vOrig
[v
];
130 SListPure
<edge
> edges
;
133 SListConstIterator
<edge
> it
;
134 for(it
= edges
.begin(); it
.valid(); ++it
)
135 moveSource(*it
,vPrime
);
143 // builds expansion graph of graph G
144 // for debugging purposes only
145 void ExpansionGraph::init(const Graph
&G
)
147 // remove previous component
149 forall_nodes(v
,*this) {
150 node vOrig
= m_vOrig
[v
];
157 // create new component
164 edge eCopy
= newEdge(getCopy(e
->source()),getCopy(e
->target()));
169 forall_nodes(v
,*this)
171 if (original(v
) && v
->indeg() >= 1 && v
->outdeg() >= 1) {
172 node vPrime
= newNode();
174 SListPure
<edge
> edges
;
177 SListConstIterator
<edge
> it
;
178 for(it
= edges
.begin(); it
.valid(); ++it
)
179 moveSource(*it
,vPrime
);
187 } // end namespace ogdf