47class EdgeWeightedGraphCopy;
49namespace steiner_tree {
51#define OGDF_FULLCOMPONENTSTORE_REMOVE_IN_GRAPH_REPRESENTATION_ALSO
54template<
typename T,
typename ExtraDataType =
void>
64 template<
class Y,
class Enable =
void>
74 struct Metadata<Y, typename
std::enable_if<!std::is_void<Y>::value>::type> {
103 for (
node v : nonterminals) {
105 edge e = adj->theEdge();
135 T weight = comp.
weight(e);
172 bool existNoncritical =
false;
177 if (v->degree() > 2) {
181 nonterminals.
push(vC);
183 existNoncritical =
true;
193 if (existNoncritical) {
194 if (nonterminals.
empty()) {
212 for (
node vC : nonterminals) {
221#ifdef OGDF_FULLCOMPONENTSTORE_REMOVE_IN_GRAPH_REPRESENTATION_ALSO
223 if (comp.terminals.size() == 2) {
224 m_graph.delEdge(comp.start->theEdge());
227 stack.
push(comp.start->twinNode());
228 m_graph.delEdge(comp.start->theEdge());
229 while (!stack.
empty()) {
233 stack.
push(adj->twinNode());
264 return m_components[id].terminals.linearSearch(t) != -1;
289 template<
typename Fun>
300 while (!stack.
empty()) {
312 template<
typename Fun>
319 template<
typename Fun>
330 template<
typename Fun>
341 v = pred[u][v]->opposite(v);
360template<
typename T,
typename ExtraDataType>
373 const ExtraDataType&
extra(
int i)
const {
438 for (
edge e : zeroEdges) {
443 for (
int id = 0;
id < this->
size(); ++id) {
446 if (!isLossEdge[e]) {
447 this->
extra(
id).bridges.pushBack(e);
Declaration and implementation of Array class and Array algorithms.
Declaration and implementation of ArrayBuffer class.
Declaration of class EdgeWeightedGraph.
Includes declaration of graph class.
Decralation of GraphElement and GraphList classes.
Declaration of doubly linked lists and iterators.
Basic declarations, included by all source files.
Class for adjacency list elements.
adjEntry twin() const
Returns the corresponding adjacency element associated with the same edge.
adjEntry cyclicSucc() const
Returns the cyclic successor in the adjacency list.
edge theEdge() const
Returns the edge associated with this adjacency entry.
node twinNode() const
Returns the associated node of the corresponding adjacency entry (shorthand for twin()->theNode()).
node theNode() const
Returns the node whose adjacency list contains this element.
An array that keeps track of the number of inserted elements; also usable as an efficient stack.
E popRet()
Removes the newest element from the buffer and returns it.
void push(E e)
Puts a new element in the buffer.
bool empty() const
Returns true if the buffer is empty, false otherwise.
The parameterized class Array implements dynamic arrays of type E.
void grow(INDEX add, const E &x)
Enlarges the array by add elements and sets new elements to x.
void quicksort()
Sorts array using Quicksort.
INDEX size() const
Returns the size (number of elements) of the array.
Class for the representation of edges.
adjEntry adjSource() const
Returns the corresponding adjacancy entry at source node.
adjEntry adjTarget() const
Returns the corresponding adjacancy entry at target node.
node target() const
Returns the target node of the edge.
node source() const
Returns the source node of the edge.
T weight(const edge e) const
const Graph & original() const
Returns a reference to the original graph.
edge copy(edge e) const override
Returns the first edge in the list of edges corresponding to edge e.
int numberOfNodes() const
Returns the number of nodes in the graph.
internal::GraphObjectContainer< NodeElement > nodes
The container containing all node objects.
bool empty() const
Returns true iff the graph is empty, i.e., contains no nodes.
internal::GraphObjectContainer< EdgeElement > edges
The container containing all edge objects.
Doubly linked lists (maintaining the length of the list).
iterator pushBack(const E &x)
Adds element x at the end of the list.
Encapsulates a pointer to a list element.
ListIteratorBase< E, isConst, isReverse > succ() const
Returns successor iterator.
Class for the representation of nodes.
internal::GraphObjectContainer< AdjElement > adjEntries
The container containing all entries in the adjacency list of this node.
int index() const
Returns the (unique) node index.
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
RegisteredArray for nodes, edges and adjEntries of a graph.
A data structure to store full components.
void remove(int id)
Removes a component by its id.
void foreachNode(int id, const NodeArray< NodeArray< edge > > &pred, Fun f) const
const NodeArray< bool > & m_isTerminal
Incidence vector for terminal nodes.
EdgeWeightedGraph< T > m_graph
Our graph representation for the full component store.
NodeArray< node > m_nodeCopy
Mapping of original terminals to m_graph nodes.
bool isTerminal(node v) const
void copyEdgesWithSimplifiedPaths(Metadata< ExtraDataType > &data, const EdgeWeightedGraphCopy< T > &comp, const ArrayBuffer< node > &nonterminals)
Copy edges from comp into our representation, traversing variant to ignore degree-2 nodes.
void traverseOverDegree2Nonterminals(node &uO, T &weight, EdgeArray< bool > &marked, adjEntry adj, const EdgeWeightedGraphCopy< T > &comp) const
Traverse over degree-2 nonterminals.
bool isEmpty() const
Checks if the store does not contain any full components.
const EdgeWeightedGraph< T > & m_originalGraph
The original Steiner instance.
const List< node > & m_terminals
The terminal list of the original Steiner instance.
ArrayBuffer< Metadata< ExtraDataType > > m_components
List of full components (based on metadata)
bool isTerminal(int id, node t) const
checks if a given node t is a terminal in the full component with given id
void copyEdges(Metadata< ExtraDataType > &data, const EdgeWeightedGraphCopy< T > &comp)
Copy edges from comp into our representation.
void foreachEdge(int id, const NodeArray< NodeArray< edge > > &pred, Fun f) const
NodeArray< node > m_nodeOrig
Mapping of m_graph nodes to original nodes.
adjEntry start(int i) const
FullComponentStore(const EdgeWeightedGraph< T > &G, const List< node > &terminals, const NodeArray< bool > &isTerminal)
T cost(int i) const
Returns the sum of edge costs of this full component.
const EdgeWeightedGraph< T > & graph() const
node original(node v) const
void foreachNode(int id, Fun f) const
void foreachAdjEntry(int i, Fun f) const
const Array< node > & terminals(int id) const
Returns the list of terminals in the full component with given id.
void insert(const EdgeWeightedGraphCopy< T > &comp)
Inserts a component. Note that comp is copied and degree-2 nodes are removed.
int size() const
Returns the number of full components in the store.
A data structure to store full components with additional "loss" functionality.
void computeAllLosses()
Compute the loss, both edge set and value, of all full components.
node lossTerminal(node v) const
Returns the terminal (in the original graph) that belongs to a given node v (in the store) according ...
const List< edge > & lossBridges(int id) const
Returns a list of non-loss edges (that are bridges between the Loss components) of full component wit...
NodeArray< node > m_lossTerminal
Indicates which Steiner node is connected to which terminal through the loss edges,...
node findLossTerminal(const node u, const NodeArray< edge > &pred)
Starting from a Steiner node find the nearest terminal along a shortest path.
T loss(int id) const
Returns the loss value of full component with given id.
Declarations for Comparer objects.
T computeMinST(const Graph &G, const EdgeArray< T > &weight, EdgeArray< bool > &isInTree)
Computes a minimum spanning tree using Prim's algorithm.
bool isTree(const Graph &G)
Returns true iff G is a tree, i.e. contains no undirected cycle and is connected.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
The namespace for all OGDF objects.
Compare elements based on a single comparable attribute.