The Original CHomP Software
Public Member Functions | Protected Attributes | List of all members
chomp::homology::PredecessorsCycle Class Reference

A helper class for determining a cycle that realizes the minimum. More...

#include <digraph.h>

Public Member Functions

 PredecessorsCycle ()
 The default constructor. More...
 
void add (int_t vertex, int_t predecessor, int_t stage)
 Adds a predecessor information for the given vertex at the given stage (path progression length). More...
 
template<class VectorType >
void getCycle (VectorType &cycle) const
 Fills in a vector with a cycle that realizes the minimum, using the push_back method to add the consecutive vertices. More...
 

Protected Attributes

chomp::homology::multitable< chomp::homology::multitable< int_t > > pred
 The array of predecessors at each stage. More...
 
int_t searchStart
 The vertex number to start back-tracing the cycle from. More...
 
int_t compSize
 The size of the component with the cycle to search. More...
 

Detailed Description

A helper class for determining a cycle that realizes the minimum.

Definition at line 3294 of file digraph.h.

Constructor & Destructor Documentation

◆ PredecessorsCycle()

chomp::homology::PredecessorsCycle::PredecessorsCycle ( )
inline

The default constructor.

Definition at line 3326 of file digraph.h.

3326 :
3327 searchStart (-1), compSize (0)
3328{
3329 return;
3330} /* PredecessorsCycle::PredecessorsCycle */
int_t searchStart
The vertex number to start back-tracing the cycle from.
Definition: digraph.h:3319
int_t compSize
The size of the component with the cycle to search.
Definition: digraph.h:3322

Member Function Documentation

◆ add()

void chomp::homology::PredecessorsCycle::add ( int_t  vertex,
int_t  predecessor,
int_t  stage 
)
inline

Adds a predecessor information for the given vertex at the given stage (path progression length).

If called with stage == -n then this means that the minimizing vertex at stage n is provided (to trace back the cycle from) with the component size.

Definition at line 3332 of file digraph.h.

3334{
3335 if (stage >= 0)
3336 {
3337 pred [stage] [vertex] = predecessor;
3338 }
3339 else
3340 {
3341 searchStart = vertex;
3342 compSize = -stage;
3343 }
3344 return;
3345} /* PredecessorsCycle::add */
chomp::homology::multitable< chomp::homology::multitable< int_t > > pred
The array of predecessors at each stage.
Definition: digraph.h:3316

References compSize, pred, and searchStart.

◆ getCycle()

template<class VectorType >
void chomp::homology::PredecessorsCycle::getCycle ( VectorType &  cycle) const
inline

Fills in a vector with a cycle that realizes the minimum, using the push_back method to add the consecutive vertices.

Definition at line 3348 of file digraph.h.

3349{
3350 // return no cycle if no information is available
3351 if ((searchStart < 0) || (compSize <= 0))
3352 return;
3353
3354 // search for a cycle and return the first cycle found;
3355 // not a very efficient way: just store the path in a vector
3356 // and check if the newly added vertes is already there
3357 int_t current (searchStart);
3358 std::vector<int_t> path;
3359 for (int_t stage = compSize; stage >= 0; -- stage)
3360 {
3361 for (size_t n = 0; n < path. size (); ++ n)
3362 {
3363 if (path [n] == current)
3364 {
3365 for (size_t m = path. size ();
3366 m > n; -- m)
3367 {
3368 cycle. push_back (path [m - 1]);
3369 }
3370 return;
3371 }
3372 }
3373 path. push_back (current);
3374 current = pred [stage] [current];
3375 }
3376 return;
3377} /* PredecessorsCycle::getCycle */
int int_t
Index type for indexing arrays, counting cubes, etc.
Definition: config.h:115

References compSize, pred, and searchStart.

Member Data Documentation

◆ compSize

int_t chomp::homology::PredecessorsCycle::compSize
protected

The size of the component with the cycle to search.

Definition at line 3322 of file digraph.h.

Referenced by add(), and getCycle().

◆ pred

chomp::homology::multitable<chomp::homology::multitable<int_t> > chomp::homology::PredecessorsCycle::pred
protected

The array of predecessors at each stage.

The first index to the array is the stage, the second index is the vertex number, and the entry is the predecessor number.

Definition at line 3316 of file digraph.h.

Referenced by add(), and getCycle().

◆ searchStart

int_t chomp::homology::PredecessorsCycle::searchStart
protected

The vertex number to start back-tracing the cycle from.

Definition at line 3319 of file digraph.h.

Referenced by add(), and getCycle().


The documentation for this class was generated from the following file: