Open
Graph Drawing
Framework

 v. snapshot-2017-02-16
 

ClusterAnalysis.h
Go to the documentation of this file.
1 
40 #pragma once
41 
43 #include <ogdf/basic/Skiplist.h>
44 #include <ogdf/basic/HashArray.h>
45 
46 namespace ogdf {
47 
48 /***
49  * @ingroup ga-cplanarity
50  *
51  * Although most parts of the code are written with efficiency in mind,
52  * this class is meant to be used in a static one-time analysis way,
53  * not for dynamic checks over and over again.
54  */
56 
57 public:
58  static const int IsNotActiveBound;
59  static const int DefaultIndex; // Vertex index for independent bags, used to detect processing status.
60 
64  explicit ClusterAnalysis(const ClusterGraph &C, bool indyBags = false);
66  ClusterAnalysis(const ClusterGraph &C, bool oalists, bool indyBags);
68 
69  // Quantitative
71  // @param c is the cluster for which the active vertices are counted
72  int outerActive(cluster c);
73 
75  // @param c is the cluster for which the active vertices are counted
76  int innerActive(cluster c);
77 
80  int minIOALevel(node v) const {
81  return min(minIALevel(v), minOALevel(v));
82  }
85  int minIALevel(node v) const {
86  return m_ialevel[v];
87  }
90  int minOALevel(node v) const {
91  return m_oalevel[v];
92  }
93 
94  // Qualitative
96 
100  bool isOuterActive(node v, cluster c);
101  bool isInnerActive(node v, cluster c);
102 
105 
109 
111  int bagIndex(node v, cluster c);
112 
114  int numberOfBags(cluster c);
115 
116 #if 0
117  //TODO
118  void reInit(const ClusterGraph &C);
119 #endif
120 
123  int indyBagIndex(node v);
124 
128 
132  cluster indyBagRoot(int i);
133 
134 protected:
137  void computeBags();
138 
141  void computeIndyBags();
142 
143 private:
150  HashArray<int, List<node> > & bagNodes, HashArray<int, bool> & indyBag,
151  Skiplist<int*> &indexNumbers, Array<cluster> & bagRoots);
152  void init();
153  void cleanUp();
155  // we keep data structures to save inner/outer activity status
156  // instead of computing them on the fly when needed
157  // keep number of activity defining adjacent edges
160 
164 
167 
171 
175  const bool m_storeoalists;
176 
178 
181  const bool m_indyBags;
183  int m_numIndyBags; //<! Number of independent bags in clustergraph
184  cluster* m_indyBagRoots; //<! Root clusters of independent bags (only when computed).
185 };
186 }
List< edge > & lcaEdges(cluster c)
Returns list of edges for cluster c with lca c.
NodeArray< int > m_ialevel
List< node > & oaNodes(cluster c)
Returns list of outeractive vertices for cluster c. The result is only valid if lists are stored...
Declaration and implementation of HashArray class.
bool isInnerActive(node v, cluster c)
The parameterized class Array implements dynamic arrays of type E.
Definition: Array.h:56
Derived class of GraphObserver providing additional functionality to handle clustered graphs...
ClusterArray< int > * m_oanum
Number of outer active vertices.
Indexed arrays using hashing for element access.
Definition: HashArray.h:94
void computeIndyBags()
Compute independent bags per cluster and store result as vertex-indyBag index in m_indyBagNumber.
NodeArray< ClusterArray< int > * > m_iactive
static const int DefaultIndex
cluster indyBagRoot(int i)
Returns root cluster of independent bag. Note that this cluster either has direct vertex members or m...
const bool m_storeoalists
If set to true (default) lists of outeractive vertices are stored.
int innerActive(cluster c)
Returns number of inneractive vertices of cluster c.
const bool m_indyBags
If true, a node partition into independent bags is computed which can be used for dividing the input ...
static const int IsNotActiveBound
int bagIndex(node v, cluster c)
Returns bag index number for a vertex v in cluster c.
NodeArray< ClusterArray< int > * > m_bagindex
We store the bag affiliation of the vertices for each cluster. A value of -1 indicates that the verte...
ClusterArray< List< node > > * m_oalists
For each cluster we store the outeractive vertices. In case you want to save space, set m_storeoalists to false.
const ClusterGraph * m_C
Representation of clustered graphs.
Definition: ClusterGraph.h:291
Dynamic arrays indexed with nodes.
Definition: Graph_d.h:423
bool isOuterActive(node v, cluster c)
Returns outer activity status for vertex v wrt cluster c.
int minIOALevel(node v) const
Returns the highest (smallest) level depth for which a vertex is inner or outer active.
ClusterArray< int > * m_bags
Number of bags per cluster (stored even if vertex list is not stored)
ClusterArray< List< edge > > * m_lcaEdges
For each cluster c we store the edges with lca c.
Class for the representation of nodes.
Definition: Graph_d.h:167
ClusterArray< int > * m_ianum
Number of inner active vertices.
Encapsulates a pointer to a list element.
Definition: List.h:41
int indyBagIndex(node v)
Returns independent bag index number for a vertex v.
void init()
Initialize the structures, performs analyses.
Representation of clusters in a clustered graph.
Definition: ClusterGraph.h:53
int minIALevel(node v) const
Returns the highest (smallest) level depth for which a vertex is inner active, only initialized if ve...
int numberOfBags(cluster c)
Returns number of bags for cluster c.
void partitionCluster(ListConstIterator< node > &nodeIt, cluster c, HashArray< int, List< node > > &bagNodes, HashArray< int, bool > &indyBag, Skiplist< int *> &indexNumbers, Array< cluster > &bagRoots)
Runs through a list of vertices (starting with the one nodeIT points to) which is expected to be a fu...
The namespace for all OGDF objects.
NodeArray< ClusterArray< int > * > m_oactive
void cleanUp()
Deletes dynamically allocated structures.
int numberOfIndyBags()
Returns number of independent bags in clustergraph, -1 in case no independent bags were computed...
void computeBags()
Compute bags per cluster and store result as vertex-bag index in m_bagIndex.
NodeArray< int > m_indyBagNumber
Each independent bag has a different number.
A randomized skiplist.
Definition: Skiplist.h:50
ClusterAnalysis(const ClusterGraph &C, bool indyBags=false)
Constructor. Performs all analyses and in case indyBags is set to true, also computes a partition int...
int outerActive(cluster c)
Returns number of outeractive vertices of cluster c.
NodeArray< int > m_oalevel
Declaration of class Skiplist.
int minOALevel(node v) const
Returns the highest (smallest) level depth for which a vertex is outer active, only initialized if ve...