116 void getClusterInducedNodes(
List<node> &clusterNodes);
125 m_id(
id), m_depth(0), m_parent(
nullptr), m_pPrev(
nullptr), m_pNext(
nullptr),
126 m_pClusterGraph(pClusterGraph) { }
129 m_id(id), m_depth(0), m_parent(nullptr), m_pPrev(nullptr), m_pNext(nullptr) { }
139 const ClusterGraph *graphOf()
const {
return m_pClusterGraph; }
147 int depth()
const {
return m_depth; }
169 clusterNodes.
clear();
170 getClusterInducedNodes(clusterNodes);
181 getClusterInducedNodes(clusterNode, num);
229 #define forall_cluster_adj(adj,c)\ 230 for(ogdf::ListConstIterator<adjEntry> ogdf_loop_var=(c)->firstAdj();\ 231 ogdf::test_forall_adj_entries_of_cluster(ogdf_loop_var,(adj));\ 232 ogdf_loop_var=ogdf_loop_var.succ()) 236 #define forall_cluster_rev_adj(adj,c)\ 237 for(ogdf::ListConstIterator<adjEntry> ogdf_loop_var=(c)->lastAdj();\ 238 ogdf::test_forall_adj_entries_of_cluster(ogdf_loop_var,(adj));\ 239 ogdf_loop_var=ogdf_loop_var.pred()) 243 #define forall_cluster_adj_edges(e,c)\ 244 for(ogdf::ListConstIterator<adjEntry> ogdf_loop_var=(c)->firstAdj();\ 245 ogdf::test_forall_adj_edges_of_cluster(ogdf_loop_var,(e));\ 246 ogdf_loop_var=ogdf_loop_var.succ()) 250 if (it.
valid()) { adj = (*it);
return true; }
257 if (adj) { e = adj->
theEdge();
return true; }
263 if (adj) { e = adj->
theEdge();
return true; }
270 #define forall_clusters(c,C) for((c)=(C).firstCluster(); (c); (c)=(c)->succ()) 274 #define forall_postOrderClusters(c,C)\ 275 for((c)=(C).firstPostOrderCluster(); (c); (c)=(c)->pSucc()) 279 class ClusterArrayBase;
280 template<
class T>
class ClusterArray;
311 #ifndef OGDF_MEMORY_POOL_NTS 425 if (!m_depthUpToDate)
426 computeSubTreeDepth(rootCluster());
439 if (!m_postOrderStart) postOrder();
440 return m_postOrderStart;
444 template<
class CLUSTERLIST>
448 clusterList.pushBack(c);
464 void clearClusterTree(
cluster C);
470 cluster createEmptyCluster(
const cluster parent =
nullptr,
int clusterId = -1);
504 template<
class NODELIST>
507 m_adjAvailable =
false;
509 m_postOrderStart =
nullptr;
510 node v = nodes.popFrontRet();
511 while (!nodes.empty())
513 node w = nodes.popFrontRet();
515 while (adj !=
nullptr)
521 else if (e->
source() == w)
533 c->m_entries.del(m_itMap[w]);
535 removeNodeAssignment(w);
554 if (!b) m_depthUpToDate =
false;
562 int treeDepth()
const;
565 void computeSubTreeDepth(
cluster c)
const;
576 return commonClusterLastAncestors(v, w, c1, c2);
587 return commonClusterAncestorsPath(v, w, c1, c2, eL);
600 return commonClusterAncestorsPath(v, w, c1, c2, eL);
604 cluster commonClusterAncestorsPath(
625 if (!c)
return false;
634 if (!c)
return false;
646 template<
class EDGELIST>
659 template<
class ADJLIST>
665 entries.pushBack(adj);
670 template<
class LISTITERATOR>
675 for (its = start; its.valid(); its++)
693 bool representsCombEmbedding()
const;
696 void consistencyCheck()
const;
730 operator const Graph &()
const {
return *m_pGraph; }
752 const cluster parent,
int clusterId = -1);
758 const cluster parent,
int clusterId = -1);
781 virtual void nodeDeleted(
node v)
override;
785 assignNode(v, rootCluster());
811 emptyCluster.
clear();
813 for (
cluster cc : clusterList) {
814 if (cc->cCount() + cc->nCount() == 0
815 && cc != rootCluster()) {
823 m_adjAvailable =
false;
825 clearClusterTree(child, attached);
830 void constructClusterTree(
834 std::function<
node(
node)> nodeMap = [](
node v) {
return v; });
840 void unassignNode(
node v);
848 c2->
nodes.del(m_itMap[v]);
849 m_nodeMap[v] =
nullptr;
881 void initGraph(
const Graph &G);
884 void reinitGraph(
const Graph &G);
893 void postOrder()
const;
896 void checkPostOrder()
const;
node target() const
Returns the target node of the edge.
Declaration of singly linked lists and iterators.
cluster m_parent
The parent of this cluster.
void clear()
Removes all elements from the list.
cluster commonClusterLastAncestors(node v, node w, cluster &c1, cluster &c2) const
Returns the lowest common cluster lca and the highest ancestors on the path to lca.
bool emptyOnClusterDelete(cluster c)
Returns true if cluster c has only one child and no nodes.
Abstract base class for cluster arrays.
cluster m_pPrev
The postorder predecessor of this cluster.
virtual void nodeAdded(node v) override
Implementation of inherited method: Updates data if node added.
virtual void edgeDeleted(edge) override
Implementation of inherited method: Updates data if edge deleted.
edge theEdge() const
Returns the edge associated with this adjacency entry.
void reInit(Graph &G)
Clear cluster info structure, reinitializes with underlying graph G.
void adjEntries(cluster c, ADJLIST &entries) const
Returns the list of all adjacency entries adjacent to cluster c in entries.
void allClusters(CLUSTERLIST &clusterList) const
Returns the list of all clusters in clusterList.
cluster succ() const
Returns the successor of the cluster in the list of all clusters.
int m_clusterIdCount
The index assigned to the next created cluster.
ListConstIterator< node > nBegin() const
Returns the first element in list of child nodes.
void moveTarget(edge e, node w)
Moves the target node of edge e to node w.
int & clusterDepth(cluster c) const
Returns depth of cluster c in cluster tree, starting with root depth 1.
Data type for general directed graphs (adjacency list representation).
ListConstIterator< adjEntry > firstAdj() const
Returns the first adjacency entry in the list of outgoing edges.
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
#define OGDF_AUGMENT_COMPARER(type)
Add this macro to your class to turn it into a full comparer.
virtual void delNode(node v)
Removes node v and all incident edges from the graph.
#define forall_cluster_adj_edges(e, c)
Iterates over all outgoing edges.
cluster parent()
Returns the parent of the cluster.
void recurseClearClusterTreeOnChildren(cluster c, List< node > &attached)
Clears children of a cluster, used by recursive clearClusterTree.
cluster clusterOf(node v) const
Returns the cluster to which a node belongs.
bool m_depthUpToDate
Status of cluster depth information.
int numberOfClusters() const
Returns the number of clusters.
cluster commonCluster(node v, node w) const
Returns the lowest common cluster of v and w in the cluster tree.
iterator begin() const
Returns an iterator to the first element in the container.
virtual void delEdge(edge e)
Removes edge e from the graph.
void adjAvailable(bool val)
Sets the availability status of the adjacency entries.
int getClusterNodes(NodeArray< bool > &clusterNode)
Sets the entry for each node v to true if v is a member of the subgraph induced by the ClusterElement...
ClusterArray< cluster > * m_wAncestor
Used to save last search run number for commoncluster.
ClusterArray< cluster > * m_vAncestor
Used to save last search run number for commoncluster.
List< cluster > & getChildren()
Provides access to the encapsulated list of children (for friends of ClusterElement).
Dynamic arrays indexed with edges.
Abstract base class for structures on graphs, that need to be informed about graph changes (e...
virtual void cleared() override
Clears cluster data without deleting root when underlying graphs' clear method is called...
cluster pred() const
Returns the predecessor of the cluster in the list of all clusters.
void collapse(NODELIST &nodes, Graph &G)
Collapses all nodes in the list nodes to the first node; multi-edges are removed. ...
cluster rootCluster() const
Returns the root cluster.
ListConstIterator< ClusterElement * > crBegin() const
Returns the last element in the list of child clusters.
ClusterElement(int id)
Creates a new cluster element.
GraphObject * tail() const
Returns the last element in the list.
void fillEmptyClusters(SList< cluster > &emptyCluster, const T &clusterList) const
Fills emptyCluster with empty, non-root clusters from clusterList.
cluster m_postOrderStart
The first cluster in postorder.
Singly linked lists (maintaining the length of the list).
reverse_iterator rbegin() const
Returns a reverse iterator to the last element in the container.
cluster m_pNext
The postorder successor of this cluster.
cluster commonClusterPath(node v, node w, List< cluster > &eL) const
Returns lca of v and w and stores corresponding path in eL.
bool valid() const
Returns true iff the iterator points to an element.
ListPure< ClusterGraphObserver * > m_regObservers
The registered graph observers.
int size() const
Returns the number of elements in the container.
Representation of clustered graphs.
bool m_allowEmptyClusters
True if the adjacency list for each cluster is available.
ListContainer< cluster, ClusterElement > children
The container containing the child clusters (children in the cluster tree) of this cluster...
List< node > & getNodes()
Provides access to the encapsulated list of nodes (for friends of ClusterElement).
int m_id
The index of this cluster.
int index() const
Returns the (unique) index of the cluster.
GraphObject * head() const
Returns the first element in the list.
cluster firstPostOrderCluster() const
Returns the first cluster in the list of post ordered clusters.
cluster m_rootCluster
The root cluster.
int cCount()
Returns the number of child clusters.
int m_clusterArrayTableSize
The current table size of cluster arrays.
Doubly linked lists (maintaining the length of the list).
virtual void edgeAdded(edge) override
Implementation of inherited method: Updates data if edge added.
bool test_forall_adj_edges_of_cluster(ListConstIterator< adjEntry > &it, edge &e)
Class for the representation of edges.
int maxClusterIndex() const
Returns the maximal used cluster index.
Dynamic arrays indexed with clusters.
int depth() const
Returns the depth of the cluster in the cluster tree.
NodeElement * node
The type of nodes.
ListConstIterator< adjEntry > lastAdj() const
Returns the last adjacency entry in the list of outgoing edges.
The base class for objects used by (hyper)graphs.
Class for the representation of nodes.
Declaration and implementation of NodeArray class.
ClusterArray< int > * m_lcaSearch
Used to save last search run number for commoncluster.
bool m_updateDepth
Depth of clusters is always updated if set to true.
Encapsulates a pointer to a list element.
int clusterArrayTableSize() const
Returns the table size of cluster arrays associated with this graph.
bool emptyOnNodeDelete(cluster c)
Returns true if cluster c has only one node and no children.
const Graph & constGraph() const
Returns a reference to the underlying graph.
#define OGDF_NEW_DELETE
Makes the class use OGDF's memory allocator.
ListConstIterator< ClusterElement * > cBegin() const
Returns the first element in the list of child clusters.
cluster pPred() const
Returns the postorder predecessor of the cluster in the list of all clusters.
std::mutex m_mutexRegArrays
The critical section for protecting shared acces to register/unregister methods.
static int compare(const ClusterElement &x, const ClusterElement &y)
Standard Comparer (uses cluster indices).
void moveSource(edge e, node w)
Moves the source node of edge e to node w.
cluster firstCluster() const
Returns the first cluster in the list of all clusters.
ListIterator< cluster > m_it
The position of this cluster within the children list of its parent.
Representation of clusters in a clustered graph.
bool test_forall_adj_entries_of_cluster(ListConstIterator< adjEntry > &it, adjEntry &adj)
const Graph * m_pGraph
The associated graph.
SListIterator< E > pushBack(const E &x)
Adds element x at the end of the list.
int m_depth
The depth of this cluster in the cluster tree.
adjEntry succ() const
Returns the successor in the adjacency list.
NodeArray< cluster > m_nodeMap
Defines if empty clusters are deleted immediately if generated by operations.
cluster lastCluster() const
Returns the last cluster in the list of all cluster.
ListContainer< node, ClusterElement > nodes
The container containing the nodes lying (directly) in this cluster.
ListContainer< adjEntry, ClusterElement > adjEntries
The container containing the sorted list of adjacency entries of edges leaving this cluster...
void makeAdjEntries(cluster c, LISTITERATOR start)
Computes the adjacency entry list for cluster c.
void removeNodeAssignment(node v)
Remove the assignment entries for nodes. Checks if node v is currently not assigned.
List< adjEntry > & getAdjEntries()
Provides access to the encapsulated list of adjacency entries (for friends of ClusterElement).
cluster pSucc() const
Returns the postorder successor of the cluster in the list of all clusters.
Abstract base class for cluster graph observers.
int m_lcaNumber
Used to save last search run number for commoncluster.
node source() const
Returns the source node of the edge.
internal::GraphObjectContainer< ClusterElement > clusters
The container containing all cluster objects.
virtual void reInit() override
Currently does nothing.
The namespace for all OGDF objects.
void setUpdateDepth(bool b) const
Turns automatic update of node depth values on or off.
Lists of graph objects (like nodes, edges, etc.).
void clear()
Removes all elements from the list.
int nCount()
Returns the number of child nodes.
adjEntry firstAdj() const
Returns the first entry in the adjaceny list.
void adjEdges(cluster c, EDGELIST &edges) const
Returns the list of all edges adjacent to cluster c in edges.
void getClusterNodes(List< node > &clusterNodes)
Returns the list of nodes in the cluster, i.e., all nodes in the subtree rooted at this cluster...
ListPure< ClusterArrayBase * > m_regClusterArrays
The registered cluster arrays.
int size() const
Returns the number of elements in the container.
Class for adjacency list elements.
std::ostream & operator<<(std::ostream &os, const ogdf::Array< E, INDEX > &a)
Prints array a to output stream os.
Abstract Base class for graph observers.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.