|
Open Graph Drawing Framework |
v. 2023.09 (Elderberry)
|
|
|
Go to the documentation of this file.
43 #include <type_traits>
47 class EdgeWeightedGraphCopy;
49 namespace steiner_tree {
51 #define OGDF_FULLCOMPONENTSTORE_REMOVE_IN_GRAPH_REPRESENTATION_ALSO // unnecessary but may save memory
54 template<
typename T,
typename ExtraDataType =
void>
64 template<
class Y,
class Enable =
void>
103 for (
node v : nonterminals) {
105 edge e = adj->theEdge();
135 T weight = comp.
weight(e);
171 Metadata<ExtraDataType> data;
172 bool existNoncritical =
false;
181 nonterminals.
push(vC);
183 existNoncritical =
true;
186 data.terminals.grow(1, vO);
193 if (existNoncritical) {
194 if (nonterminals.
empty()) {
198 data.cost += comp.
weight(e);
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()) {
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);
360 template<
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);
An array that keeps track of the number of inserted elements; also usable as an efficient stack.
The namespace for all OGDF objects.
Declaration and implementation of ArrayBuffer class.
NodeArray< node > m_lossTerminal
Indicates which Steiner node is connected to which terminal through the loss edges,...
bool empty() const
Returns true iff the graph is empty, i.e., contains no nodes.
Includes declaration of graph class.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
bool empty() const
Returns true if the buffer is empty, false otherwise.
node original(node v) const
node theNode() const
Returns the node whose adjacency list contains this element.
const Array< node > & terminals(int id) const
Returns the list of terminals in the full component with given id.
int index() const
Returns the (unique) node index.
T computeMinST(const Graph &G, const EdgeArray< T > &weight, EdgeArray< bool > &isInTree)
Computes a minimum spanning tree using Prim's algorithm.
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.
const List< node > & m_terminals
The terminal list of the original Steiner instance.
node lossTerminal(node v) const
Returns the terminal (in the original graph) that belongs to a given node v (in the store) according ...
T loss(int id) const
Returns the loss value of full component with given id.
E popRet()
Removes the newest element from the buffer and returns it.
bool isTerminal(node v) const
adjEntry twin() const
Returns the corresponding adjacency element associated with the same edge.
const EdgeWeightedGraph< T > & m_originalGraph
The original Steiner instance.
void foreachNode(int id, Fun f) const
Class for adjacency list elements.
EdgeWeightedGraph< T > m_graph
Our graph representation for the full component store.
FullComponentStore(const EdgeWeightedGraph< T > &G, const List< node > &terminals, const NodeArray< bool > &isTerminal)
edge theEdge() const
Returns the edge associated with this adjacency entry.
internal::GraphObjectContainer< NodeElement > nodes
The container containing all node objects.
int degree() const
Returns the degree of the node (indegree + outdegree).
int numberOfNodes() const
Returns the number of nodes in the graph.
NodeArray< node > m_nodeCopy
Mapping of original terminals to m_graph nodes.
Decralation of GraphElement and GraphList classes.
internal::GraphObjectContainer< AdjElement > adjEntries
The container containing all entries in the adjacency list of this node.
void push(E e)
Puts a new element in the buffer.
T cost(int i) const
Returns the sum of edge costs of this full component.
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...
node source() const
Returns the source node of the edge.
Doubly linked lists (maintaining the length of the list).
RegisteredArray for nodes, edges and adjEntries of a graph.
adjEntry adjSource() const
Returns the corresponding adjacancy entry at source node.
void copyEdges(Metadata< ExtraDataType > &data, const EdgeWeightedGraphCopy< T > &comp)
Copy edges from comp into our representation.
ArrayBuffer< Metadata< ExtraDataType > > m_components
List of full components (based on metadata)
void traverseOverDegree2Nonterminals(node &uO, T &weight, EdgeArray< bool > &marked, adjEntry adj, const EdgeWeightedGraphCopy< T > &comp) const
Traverse over degree-2 nonterminals.
adjEntry start(int i) const
node findLossTerminal(const node u, const NodeArray< edge > &pred)
Starting from a Steiner node find the nearest terminal along a shortest path.
bool isTerminal(int id, node t) const
checks if a given node t is a terminal in the full component with given id
const EdgeWeightedGraph< T > & graph() const
node twinNode() const
Returns the associated node of the corresponding adjacency entry (shorthand for twin()->theNode()).
edge copy(edge e) const override
Returns the first edge in the list of edges corresponding to edge e.
A data structure to store full components.
adjEntry cyclicSucc() const
Returns the cyclic successor in the adjacency list.
void foreachNode(int id, const NodeArray< NodeArray< edge >> &pred, Fun f) 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.
adjEntry adjTarget() const
Returns the corresponding adjacancy entry at target node.
bool isEmpty() const
Checks if the store does not contain any full components.
internal::GraphObjectContainer< EdgeElement > edges
The container containing all edge objects.
A data structure to store full components with additional "loss" functionality.
Declaration of class EdgeWeightedGraph.
Basic declarations, included by all source files.
const NodeArray< bool > & m_isTerminal
Incidence vector for terminal nodes.
T weight(const edge e) const
Declaration and implementation of Array class and Array algorithms.
Class for the representation of edges.
Declaration of doubly linked lists and iterators.
void foreachAdjEntry(int i, Fun f) const
INDEX size() const
Returns the size (number of elements) of the array.
NodeArray< node > m_nodeOrig
Mapping of m_graph nodes to original nodes.
Encapsulates a pointer to a list element.
void remove(int id)
Removes a component by its id.
node target() const
Returns the target node of the edge.
void computeAllLosses()
Compute the loss, both edge set and value, of all full components.
Declarations for Comparer objects.
Class for the representation of nodes.
void foreachEdge(int id, const NodeArray< NodeArray< edge >> &pred, Fun f) const
Compare elements based on a single comparable attribute.
bool isTree(const Graph &G)
Returns true iff G is a tree, i.e. contains no undirected cycle and is connected.
iterator pushBack(const E &x)
Adds element x at the end of the list.
const Graph & original() const
Returns a reference to the original graph.
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.