|
Open Graph Drawing Framework |
v. 2023.09 (Elderberry)
|
|
|
Go to the documentation of this file.
116 void getClusterInducedNodes(
List<node>& clusterNodes);
129 , m_pClusterGraph(pClusterGraph) { }
132 : m_id(id), m_depth(0), m_parent(nullptr), m_pPrev(nullptr), m_pNext(nullptr) { }
150 int depth()
const {
return m_depth; }
172 clusterNodes.
clear();
173 getClusterInducedNodes(clusterNodes);
184 getClusterInducedNodes(clusterNode, num);
199 while (child !=
this) {
200 if (child ==
nullptr) {
250 #define forall_cluster_adj(adj, c) \
251 for (ogdf::ListConstIterator<adjEntry> ogdf_loop_var = (c)->firstAdj(); \
252 ogdf::test_forall_adj_entries_of_cluster(ogdf_loop_var, (adj)); \
253 ogdf_loop_var = ogdf_loop_var.succ())
257 #define forall_cluster_rev_adj(adj, c) \
258 for (ogdf::ListConstIterator<adjEntry> ogdf_loop_var = (c)->lastAdj(); \
259 ogdf::test_forall_adj_entries_of_cluster(ogdf_loop_var, (adj)); \
260 ogdf_loop_var = ogdf_loop_var.pred())
264 #define forall_cluster_adj_edges(e, c) \
265 for (ogdf::ListConstIterator<adjEntry> ogdf_loop_var = (c)->firstAdj(); \
266 ogdf::test_forall_adj_edges_of_cluster(ogdf_loop_var, (e)); \
267 ogdf_loop_var = ogdf_loop_var.succ())
299 #define forall_clusters(c, C) for ((c) = (C).firstCluster(); (c); (c) = (c)->succ())
303 #define forall_postOrderClusters(c, C) \
304 for ((c) = (C).firstPostOrderCluster(); (c); (c) = (c)->pSucc())
310 template<
typename Value,
bool WithDefault>
313 #define OGDF_DECL_REG_ARRAY_TYPE(v, c) ClusterArrayBase<v, c>
315 #undef OGDF_DECL_REG_ARRAY_TYPE
332 virtual void clusterDeleted(
cluster v) = 0;
333 virtual void clusterAdded(
cluster v) = 0;
334 virtual void clustersCleared() = 0;
348 public Observable<ClusterGraphObserver, ClusterGraph>,
351 int m_clusterIdCount = 0;
356 bool m_adjAvailable =
false;
357 bool m_allowEmptyClusters =
459 if (!m_depthUpToDate) {
460 computeSubTreeDepth(rootCluster());
474 if (!m_postOrderStart) {
477 return m_postOrderStart;
481 template<
class CLUSTERLIST>
485 clusterList.pushBack(c);
502 void clearClusterTree(
cluster C);
508 cluster createEmptyCluster(
const cluster parent =
nullptr,
int clusterId = -1);
540 void copyClusterTree(
542 std::function<
node(
node)> nodeMap = [](
node v) {
return v; });
545 template<
class NODELIST>
548 m_adjAvailable =
false;
550 m_postOrderStart =
nullptr;
551 node v = nodes.popFrontRet();
552 while (!nodes.empty()) {
553 node w = nodes.popFrontRet();
555 while (adj !=
nullptr) {
560 }
else if (e->
source() == w) {
573 c->m_entries.del(m_itMap[w]);
575 removeNodeAssignment(w);
597 std::function<
bool(
cluster)> includeCluster = [](
cluster) {
return true; },
598 bool isFastTest =
true)
const;
606 m_depthUpToDate =
false;
615 int treeDepth()
const;
618 void computeSubTreeDepth(
cluster c)
const;
629 return commonClusterLastAncestors(v, w, c1, c2);
635 return commonClusterAncestorsPath(v, w, c1, c2, eL);
644 return commonClusterAncestorsPath(v, w, c1, c2, eL);
690 template<
class EDGELIST>
694 if (m_adjAvailable) {
703 template<
class ADJLIST>
706 if (m_adjAvailable) {
708 entries.pushBack(adj);
714 template<
class LISTITERATOR>
718 for (its = start; its.valid(); its++) {
742 bool representsCombEmbedding()
const;
753 bool representsConnectedCombEmbedding()
const;
756 void consistencyCheck()
const;
771 if (key ==
nullptr) {
776 OGDF_ASSERT(keyToIndex(key) < this->getArraySize());
801 operator const Graph&()
const {
return *getGraph(); }
813 mutable int m_lcaNumber = 0;
817 mutable bool m_updateDepth =
false;
818 mutable bool m_depthUpToDate =
false;
827 const cluster parent,
int clusterId = -1);
850 void nodeDeleted(
node v)
override;
868 void registrationChanged(
const Graph* newG)
override;
876 emptyCluster.
clear();
878 for (
cluster cc : clusterList) {
879 if (cc->cCount() + cc->nCount() == 0 && cc != rootCluster()) {
887 m_adjAvailable =
false;
889 clearClusterTree(child, attached);
897 void unassignNode(
node v);
905 c2->
nodes.del(m_itMap[v]);
906 m_nodeMap[v] =
nullptr;
933 void initGraph(
const Graph& G);
936 void reinitGraph(
const Graph& G);
945 void postOrder()
const;
948 void checkPostOrder()
const;
956 template<
class Value,
bool WithDefault>
957 class ClusterArrayBase :
public RegisteredArray<ClusterGraph, Value, WithDefault> {
968 RA::resize(size,
true);
991 EdgeArray<List<std::pair<adjEntry, cluster>>>* subdivisions,
992 const std::function<
edge(
edge)>& translate);
Abstract base class for registries.
The namespace for all OGDF objects.
void nodeAdded(node v) override
Implementation of inherited method: Updates data if node added.
Dynamic arrays indexed with arbitrary keys.
#define OGDF_DECL_REG_ARRAY(NAME)
int size() const
Returns the size of the list.
std::unique_ptr< ClusterArray< int > > m_lcaSearch
Used to save last search run number for commoncluster.
Includes declaration of graph class.
ClusterArrayBase(const ClusterGraph &C, const Value &def, int size)
Creates a new cluster array with initial capacity size.
GraphObject * tail() const
Returns the last element in the list.
const ClusterGraph * getGraph() const
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
cluster lastCluster() const
Returns the last cluster in the list of all cluster.
void makeAdjEntries(cluster c, LISTITERATOR start)
Computes the adjacency entry list for cluster c.
bool test_forall_adj_edges_of_cluster(ListConstIterator< adjEntry > &it, edge &e)
typename std::conditional< WithDefault, internal::RegisteredArrayWithDefault< Registry, Value >, internal::RegisteredArrayWithoutDefault< Registry, Value > >::type RA
NodeArray< cluster > m_nodeMap
Defines if empty clusters are deleted immediately if generated by operations.
The base class for objects used by (hyper)graphs.
internal::EdgeArrayBase2< Value, WithDefault > EdgeArray
RegisteredArray for labeling the edges in a Graph with an arbitrary Value.
#define OGDF_AUGMENT_COMPARER(type)
Add this macro to your class to turn it into a full comparer.
const Graph & constGraph() const
Returns a reference to the underlying graph.
RegisteredArray for labeling the clusters of a ClusterGraph.
void getClusterNodes(List< node > &clusterNodes)
Returns the list of nodes in the cluster, i.e., all nodes in the subtree rooted at this cluster.
cluster firstCluster() const
Returns the first cluster in the list of all clusters.
Simple, safe base classes for C++ observables and observers.
void setUpdateDepth(bool b) const
Turns automatic update of node depth values on or off.
#define forall_cluster_adj_edges(e, c)
Iterates over all outgoing edges.
Singly linked lists (maintaining the length of the list).
bool emptyOnNodeDelete(cluster c)
Returns true if cluster c has only one node and no children.
List< node > & getNodes()
Provides access to the encapsulated list of nodes (for friends of ClusterElement).
int cCount()
Returns the number of child clusters.
bool valid() const
Returns true iff the iterator points to an element.
int maxClusterIndex() const
Returns the maximal used cluster index.
void edgeAdded(edge) override
Implementation of inherited method: Updates data if edge added.
cluster pred() const
Returns the predecessor of the cluster in the list of all clusters.
Public read-only interface for lists of graph objects.
void removeNodeAssignment(node v)
Remove the assignment entries for nodes. Checks if node v is currently not assigned.
int m_id
The index of this cluster.
Abstract base class for cluster graph observers.
static int compare(const ClusterElement &x, const ClusterElement &y)
Standard Comparer (uses cluster indices).
cluster pPred() const
Returns the postorder predecessor of the cluster in the list of all clusters.
#define OGDF_NEW_DELETE
Makes the class use OGDF's memory allocator.
std::unique_ptr< ClusterArray< cluster > > m_wAncestor
Used to save last search run number for commoncluster.
void cleared() override
Clears cluster data without deleting root when underlying graphs' clear method is called.
void edgeDeleted(edge) override
Implementation of inherited method: Updates data if edge deleted.
ClusterElement * cluster
The type of clusters.
reverse_iterator rbegin() const
Returns a reverse iterator to the last element in the container.
Class for adjacency list elements.
ListContainer< cluster, ClusterElement > children
The container containing the child clusters (children in the cluster tree) of this cluster.
int size() const
Returns the number of elements in the container.
EdgeElement * edge
The type of edges.
Representation of clusters in a clustered graph.
edge theEdge() const
Returns the edge associated with this adjacency entry.
const ClusterGraph * graphOf() const
cluster m_parent
The parent of this cluster.
Base class for an observable object that can be tracked by multiple Observer objects.
void allClusters(CLUSTERLIST &clusterList) const
Returns the list of all clusters in clusterList.
internal::GraphObjectContainer< ClusterElement > clusters
The container containing all cluster objects.
bool isDescendant(ClusterElement *child, bool allow_equal=false)
Checks whether a cluster child is a descendant (i.e. child, child of a child, ...) of this cluster.
bool adjAvailable() const
Gets the availability status of the adjacency entries.
ClusterGraphObserver(const ClusterGraph *CG)
int & clusterDepth(cluster c) const
Returns depth of cluster c in cluster tree, starting with root depth 1.
int nCount()
Returns the number of child nodes.
Declaration of singly linked lists and iterators.
Decralation of GraphElement and GraphList classes.
adjEntry succ() const
Returns the successor in the adjacency list.
void reInit(Graph &G)
Clear cluster info structure, reinitializes with underlying graph G.
void adjEdges(cluster c, EDGELIST &edges) const
Returns the list of all edges adjacent to cluster c in edges.
int calculateTableSize(int actualCount)
The default growth function for registered arrays.
Declaration and implementation of RegisteredArray class.
ClusterElement(const ClusterGraph *pClusterGraph, int id)
Creates a new cluster element.
bool isKeyAssociated(cluster key) const
cluster_iterator begin() const
iterator begin() const
Returns an iterator to the first element in the container.
cluster succ() const
Returns the successor of the cluster in the list of all clusters.
std::ostream & operator<<(std::ostream &os, const ogdf::Array< E, INDEX > &a)
Prints array a to output stream os.
cluster_iterator end() const
node source() const
Returns the source node of the edge.
NodeElement * node
The type of nodes.
Abstract Base class for graph observers.
Doubly linked lists (maintaining the length of the list).
RegisteredArray for nodes, edges and adjEntries of a graph.
Data type for general directed graphs (adjacency list representation).
bool emptyOnClusterDelete(cluster c)
Returns true if cluster c has only one child and no nodes.
Lists of graph objects (like nodes, edges, etc.).
void planarizeClusterBorderCrossings(const ClusterGraph &CG, Graph &G, EdgeArray< List< std::pair< adjEntry, cluster >>> *subdivisions, const std::function< edge(edge)> &translate)
Turn cluster borders into cycles of edges and cluster-border-edge-crossings into vertices.
cluster m_pPrev
The postorder predecessor of this cluster.
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.
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...
int m_depth
The depth of this cluster in the cluster tree.
bool test_forall_adj_entries_of_cluster(ListConstIterator< adjEntry > &it, adjEntry &adj)
void clear()
Removes all elements from the list.
ListContainer< adjEntry, ClusterElement > adjEntries
The container containing the sorted list of adjacency entries of edges leaving this cluster.
int depth() const
Returns the depth of the cluster in the cluster tree.
ListConstIterator< adjEntry > lastAdj() const
Returns the last adjacency entry in the list of outgoing edges.
void adjEntries(cluster c, ADJLIST &entries) const
Returns the list of all adjacency entries adjacent to cluster c in entries.
int calculateArraySize(int add) const
int numberOfClusters() const
Returns the number of clusters.
cluster rootCluster() const
Returns the root cluster.
iterator begin() const
Returns an iterator to the first element in the container.
void adjAvailable(bool val)
Sets the availability status of the adjacency entries.
GraphObject * head() const
Returns the first element in the list.
Base class for an observer for a single Observable object.
ListIterator< cluster > m_it
The position of this cluster within the children list of its parent.
void collapse(NODELIST &nodes, Graph &G)
Collapses all nodes in the list nodes to the first node; multi-edges are removed.
Basic declarations, included by all source files.
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
cluster commonCluster(node v, node w) const
Returns the lowest common cluster of v and w in the cluster tree.
iterator end() const
Returns an iterator to the one-past-last element in the container.
adjEntry firstAdj() const
Returns the first entry in the adjaceny list.
cluster pSucc() const
Returns the postorder successor of the cluster in the list of all clusters.
ListConstIterator< node > nBegin() const
Returns the first element in list of child nodes.
List< cluster > & getChildren()
Provides access to the encapsulated list of children (for friends of ClusterElement).
const ClusterGraph * m_pClusterGraph
Class for the representation of edges.
int index() const
Returns the (unique) index of the cluster.
void recurseClearClusterTreeOnChildren(cluster c, List< node > &attached)
Clears children of a cluster, used by recursive clearClusterTree.
Declaration of doubly linked lists and iterators.
cluster parent()
Returns the parent of the cluster.
cluster clusterOf(node v) const
Returns the cluster to which a node belongs.
std::unique_ptr< ClusterArray< cluster > > m_vAncestor
Used to save last search run number for commoncluster.
cluster m_pNext
The postorder successor of this cluster.
cluster firstPostOrderCluster() const
Returns the first cluster in the list of post ordered clusters.
ListConstIterator< ClusterElement * > cBegin() const
Returns the first element in the list of child clusters.
Encapsulates a pointer to a list element.
ListConstIterator< ClusterElement * > crBegin() const
Returns the last element in the list of child clusters.
List< adjEntry > & getAdjEntries()
Provides access to the encapsulated list of adjacency entries (for friends of ClusterElement).
ClusterGraph * graphOf() const
Returns a pointer to the associated cluster graph.
ListContainer< node, ClusterElement > nodes
The container containing the nodes lying (directly) in this cluster.
node target() const
Returns the target node of the edge.
Representation of clustered graphs.
Declarations for Comparer objects.
Class for the representation of nodes.
Declaration of memory manager for allocating small pieces of memory.
ClusterArrayBase()=default
Default Constructor.
static int keyToIndex(cluster key)
SListIterator< E > pushBack(const E &x)
Adds element x at the end of the list.
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
void fillEmptyClusters(SList< cluster > &emptyCluster, const T &clusterList) const
Fills emptyCluster with empty, non-root clusters from clusterList.
void clear()
Removes all elements from the list.
cluster commonClusterPath(node v, node w, List< cluster > &eL) const
Returns lca of v and w and stores corresponding path in eL.
ListConstIterator< adjEntry > firstAdj() const
Returns the first adjacency entry in the list of outgoing edges.