Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes

ColPack::GraphColoring Class Reference
[Classes for Graphs]

class GraphColoring in group1. More...

#include <GraphColoring.h>

Inherits ColPack::GraphOrdering.

Inherited by ColPack::GraphColoringInterface.

Collaboration diagram for ColPack::GraphColoring:
Collaboration graph
[legend]

List of all members.

Public Member Functions

double ** GetSeedMatrix (int *ip1_SeedRowCount, int *ip1_SeedColumnCount)
 Return the Seed matrix based on existing coloring. This Seed matrix is managed and freed by ColPack.
double ** GetSeedMatrix_unmanaged (int *ip1_SeedRowCount, int *ip1_SeedColumnCount)
 Same as GetSeedMatrix(), except that this Seed matrix is NOT managed by ColPack.
int CheckQuickDistanceTwoColoring (int Verbose=0)
 Quick check to see if DistanceTwoColoring() ran correctly.
int CheckDistanceTwoColoring (int Verbose=0)
 Check to see if DistanceTwoColoring() ran correctly.
int CalculateVertexColorClasses ()
void SetStringVertexColoringVariant (string s)
 GraphColoring ()
 ~GraphColoring ()
virtual void Clear ()
int DistanceOneColoring ()
int DistanceTwoColoring ()
int NaiveStarColoring ()
int RestrictedStarColoring ()
int StarColoring ()
int StarColoring (vector< int > &, vector< int > &, map< int, map< int, int > > &)
int CheckStarColoring ()
int AcyclicColoring ()
int AcyclicColoring (vector< int > &, map< int, vector< int > > &)
int AcyclicColoring_ForIndirectRecovery ()
int CheckAcyclicColoring ()
int TriangularColoring ()
int ModifiedTriangularColoring ()
int CheckTriangularColoring ()
string GetVertexColoringVariant ()
int GetVertexColorCount ()
void GetVertexColors (vector< int > &output)
int GetHubCount ()
int GetSetCount ()
double GetVertexColoringTime ()
double GetVertexColoringCheckingTime ()
int PrintVertexColors ()
int FileVertexColors ()
int PrintVertexColoringMetrics ()
int FileVertexColoringMetrics ()
void PrintVertexColorClasses ()

Protected Member Functions

void Seed_init ()
void Seed_reset ()

Protected Attributes

int m_i_VertexColorCount
int m_i_LargestColorClass
int m_i_SmallestColorClass
int m_i_LargestColorClassSize
int m_i_SmallestColorClassSize
double m_d_AverageColorClassSize
double m_d_ColoringTime
double m_d_CheckingTime
string m_s_VertexColoringVariant
vector< int > m_vi_VertexColors
vector< int > m_vi_VertexColorFrequency
bool seed_available
int i_seed_rowCount
double ** dp2_Seed

Private Member Functions

int FindCycle (int, int, int, int, vector< int > &, vector< int > &, vector< int > &)
int UpdateSet (int, int, int, map< int, map< int, int > > &, vector< int > &, vector< int > &, vector< int > &)
int SearchDepthFirst (int, int, int, vector< int > &)
int CheckVertexColoring (string s_GraphColoringVariant)

Private Attributes

int m_i_ColoringUnits

Detailed Description

class GraphColoring in group1.

Graph coloring is an assignment of consecutive integral numbers (each representing a color) to vertices, edges or faces or a combination of two or more of these objects of a graph such that it satisfes one or more constraints. The present version of ColPack provides methods for vertex coloring only. The minimum number of vertex colors required to color a graph is known as the chromatic number of the graph. The problem of finding the chromatic number for even a planar graph is NP-hard. ColPack features some of the most efficient approximation algorithms available to date for some of the vertex coloring problems.

Definition at line 38 of file GraphColoring.h.


Constructor & Destructor Documentation

ColPack::GraphColoring::GraphColoring (  ) 

Definition at line 239 of file GraphColoring.cpp.

References Clear(), and Seed_init().

Here is the call graph for this function:

ColPack::GraphColoring::~GraphColoring (  ) 

Definition at line 248 of file GraphColoring.cpp.

References Clear(), and Seed_reset().

Here is the call graph for this function:


Member Function Documentation

int ColPack::GraphColoring::AcyclicColoring (  ) 
int ColPack::GraphColoring::AcyclicColoring ( vector< int > &  vi_Sets,
map< int, vector< int > > &  mivi_VertexSets 
)
int ColPack::GraphColoring::AcyclicColoring_ForIndirectRecovery (  ) 
int ColPack::GraphColoring::CalculateVertexColorClasses (  ) 
int ColPack::GraphColoring::CheckAcyclicColoring (  ) 

Definition at line 3019 of file GraphColoring.cpp.

References _FALSE, ColPack::GraphCore::m_vi_Vertices, SearchDepthFirst(), and STEP_DOWN.

Referenced by CheckTriangularColoring().

Here is the call graph for this function:

Here is the caller graph for this function:

int ColPack::GraphColoring::CheckDistanceTwoColoring ( int  Verbose = 0  ) 

Check to see if DistanceTwoColoring() ran correctly.

100% accurate but slow. For a quick check, use CheckQuickDistanceTwoColoring().

Return value:

Precondition: DistanceTwoColoring() has been run.

Parameter: int Verbose

  • If Verbose == 0, this function will silently return after the first error is detected.
  • If Verbose == 1, this function will print out the error message and return after the first error is detected.
  • If Verbose == 2, this function will print out all the errors and then return.

Definition at line 4023 of file GraphColoring.cpp.

References ColPack::GraphCore::m_vi_Edges, m_vi_VertexColors, ColPack::GraphCore::m_vi_Vertices, STEP_DOWN, and STEP_UP.

int ColPack::GraphColoring::CheckQuickDistanceTwoColoring ( int  Verbose = 0  ) 

Quick check to see if DistanceTwoColoring() ran correctly.

Return value:

IMPORTANT: This is the quick check so if CheckQuickDistanceTwoColoring() return 1, then DistanceTwoColoring() definitely ran INcorrectly. However, when CheckQuickDistanceTwoColoring() return 0, it doesn't mean that DistanceTwoColoring() ran correctly (it may, it may not). To be 100% sure, use CheckDistanceTwoColoring()

Precondition: DistanceTwoColoring() has been run.

Parameter: int Verbose

  • If Verbose == 0, this function only check and see if m_i_MaximumVertexDegree <= m_i_VertexColorCount + 1.
  • If Verbose == 1, this function will print out the vertex with m_i_MaximumVertexDegree where the error can be detected.
  • If Verbose == 2, this function will print out all the errors (violations) and then return.

Algorithm:

Definition at line 3984 of file GraphColoring.cpp.

References ColPack::GraphCore::m_i_MaximumVertexDegree, m_i_VertexColorCount, ColPack::GraphCore::m_vi_Edges, m_vi_VertexColors, ColPack::GraphCore::m_vi_Vertices, STEP_DOWN, and STEP_UP.

int ColPack::GraphColoring::CheckStarColoring (  ) 
int ColPack::GraphColoring::CheckTriangularColoring (  ) 

Definition at line 3290 of file GraphColoring.cpp.

References CheckAcyclicColoring().

Here is the call graph for this function:

int ColPack::GraphColoring::CheckVertexColoring ( string  s_GraphColoringVariant  )  [private]
void ColPack::GraphColoring::Clear (  )  [virtual]
int ColPack::GraphColoring::DistanceOneColoring (  ) 
int ColPack::GraphColoring::DistanceTwoColoring (  ) 
int ColPack::GraphColoring::FileVertexColoringMetrics (  ) 
int ColPack::GraphColoring::FileVertexColors (  ) 
int ColPack::GraphColoring::FindCycle ( int  i_Vertex,
int  i_AdjacentVertex,
int  i_DistanceOneVertex,
int  i_SetID,
vector< int > &  vi_CandidateColors,
vector< int > &  vi_FirstVisitedOne,
vector< int > &  vi_FirstVisitedTwo 
) [private]

Definition at line 28 of file GraphColoring.cpp.

References _TRUE, _UNKNOWN, m_vi_VertexColors, and STEP_UP.

Referenced by AcyclicColoring(), and AcyclicColoring_ForIndirectRecovery().

Here is the caller graph for this function:

int ColPack::GraphColoring::GetHubCount (  ) 

Definition at line 3318 of file GraphColoring.cpp.

References _UNKNOWN, CheckVertexColoring(), and m_i_ColoringUnits.

Here is the call graph for this function:

double ** ColPack::GraphColoring::GetSeedMatrix ( int *  ip1_SeedRowCount,
int *  ip1_SeedColumnCount 
)

Return the Seed matrix based on existing coloring. This Seed matrix is managed and freed by ColPack.

Precondition:

  • the Graph has been colored

Postcondition:

  • Size of the returned matrix is (*ip1_SeedRowCount) rows x (*ip1_SeedColumnCount) columns. (*ip1_SeedRowCount) == num of columns of the original matrix == GetVertexCount() (*ip1_SeedColumnCount) == num of colors used to color vertices == GetVertexColorCount().

Notes:

  • This Seed matrix is managed and automatically freed by ColPack when the Graph object is deleted. Therefore, the user should NOT attempt to free the Seed matrix again.

Reimplemented in ColPack::GraphColoringInterface.

Definition at line 3914 of file GraphColoring.cpp.

References dp2_Seed, i_seed_rowCount, m_i_VertexColorCount, m_vi_VertexColors, seed_available, and Seed_reset().

Here is the call graph for this function:

double ** ColPack::GraphColoring::GetSeedMatrix_unmanaged ( int *  ip1_SeedRowCount,
int *  ip1_SeedColumnCount 
)

Same as GetSeedMatrix(), except that this Seed matrix is NOT managed by ColPack.

Notes:

  • This Seed matrix is NOT managed by ColPack. Therefore, the user should free the Seed matrix manually when the matrix is no longer needed.

Definition at line 3943 of file GraphColoring.cpp.

References m_i_VertexColorCount, and m_vi_VertexColors.

Referenced by ColPack::GraphColoringInterface::GenerateSeedHessian_unmanaged().

Here is the caller graph for this function:

int ColPack::GraphColoring::GetSetCount (  ) 

Definition at line 3332 of file GraphColoring.cpp.

References _UNKNOWN, CheckVertexColoring(), and m_i_ColoringUnits.

Here is the call graph for this function:

int ColPack::GraphColoring::GetVertexColorCount (  ) 
double ColPack::GraphColoring::GetVertexColoringCheckingTime (  ) 

Definition at line 3351 of file GraphColoring.cpp.

References m_d_CheckingTime.

double ColPack::GraphColoring::GetVertexColoringTime (  ) 

Definition at line 3345 of file GraphColoring.cpp.

References m_d_ColoringTime.

Referenced by toFileC(), and toFileC_forColoringBasedOrdering().

Here is the caller graph for this function:

string ColPack::GraphColoring::GetVertexColoringVariant (  ) 

Definition at line 3297 of file GraphColoring.cpp.

References m_s_VertexColoringVariant.

void ColPack::GraphColoring::GetVertexColors ( vector< int > &  output  ) 
int ColPack::GraphColoring::ModifiedTriangularColoring (  ) 
int ColPack::GraphColoring::NaiveStarColoring (  ) 
void ColPack::GraphColoring::PrintVertexColorClasses (  ) 
int ColPack::GraphColoring::PrintVertexColoringMetrics (  ) 
int ColPack::GraphColoring::PrintVertexColors (  ) 
int ColPack::GraphColoring::RestrictedStarColoring (  ) 
int ColPack::GraphColoring::SearchDepthFirst ( int  i_RootVertex,
int  i_ParentVertex,
int  i_Vertex,
vector< int > &  vi_TouchedVertices 
) [private]

Definition at line 96 of file GraphColoring.cpp.

References _TRUE, ColPack::GraphCore::m_s_InputFile, ColPack::GraphCore::m_vi_Edges, m_vi_VertexColors, ColPack::GraphCore::m_vi_Vertices, STEP_DOWN, and STEP_UP.

Referenced by CheckAcyclicColoring().

Here is the caller graph for this function:

void ColPack::GraphColoring::Seed_init (  )  [protected]

Definition at line 3966 of file GraphColoring.cpp.

References dp2_Seed, i_seed_rowCount, and seed_available.

Referenced by GraphColoring().

Here is the caller graph for this function:

void ColPack::GraphColoring::Seed_reset (  )  [protected]

Definition at line 3973 of file GraphColoring.cpp.

References dp2_Seed, free_2DMatrix(), i_seed_rowCount, and seed_available.

Referenced by GetSeedMatrix(), ~GraphColoring(), and ColPack::GraphColoringInterface::~GraphColoringInterface().

Here is the call graph for this function:

Here is the caller graph for this function:

void ColPack::GraphColoring::SetStringVertexColoringVariant ( string  s  ) 

Definition at line 4063 of file GraphColoring.cpp.

References m_s_VertexColoringVariant.

Referenced by toFileC_forColoringBasedOrdering().

Here is the caller graph for this function:

int ColPack::GraphColoring::StarColoring ( vector< int > &  vi_StarHubMap,
vector< int > &  vi_EdgeStarMap,
map< int, map< int, int > > &  mimi2_VertexEdgeMap 
)
int ColPack::GraphColoring::StarColoring (  ) 
int ColPack::GraphColoring::TriangularColoring (  ) 
int ColPack::GraphColoring::UpdateSet ( int  i_Vertex,
int  i_AdjacentVertex,
int  i_DistanceOneVertex,
map< int, map< int, int > > &  mimi2_VertexEdgeMap,
vector< int > &  vi_FirstSeenOne,
vector< int > &  vi_FirstSeenTwo,
vector< int > &  vi_FirstSeenThree 
) [private]

Definition at line 61 of file GraphColoring.cpp.

References _UNKNOWN, and m_vi_VertexColors.

Referenced by AcyclicColoring(), and AcyclicColoring_ForIndirectRecovery().

Here is the caller graph for this function:


Member Data Documentation

double** ColPack::GraphColoring::dp2_Seed [protected]

Definition at line 148 of file GraphColoring.h.

Referenced by GetSeedMatrix(), Seed_init(), and Seed_reset().

Definition at line 147 of file GraphColoring.h.

Referenced by GetSeedMatrix(), Seed_init(), and Seed_reset().

Definition at line 135 of file GraphColoring.h.

Referenced by CalculateVertexColorClasses(), Clear(), and PrintVertexColorClasses().

Definition at line 138 of file GraphColoring.h.

Referenced by Clear(), and GetVertexColoringCheckingTime().

Definition at line 129 of file GraphColoring.h.

Referenced by CalculateVertexColorClasses(), Clear(), and PrintVertexColorClasses().

Definition at line 132 of file GraphColoring.h.

Referenced by CalculateVertexColorClasses(), Clear(), and PrintVertexColorClasses().

Definition at line 130 of file GraphColoring.h.

Referenced by CalculateVertexColorClasses(), Clear(), and PrintVertexColorClasses().

Definition at line 133 of file GraphColoring.h.

Referenced by CalculateVertexColorClasses(), Clear(), and PrintVertexColorClasses().

Definition at line 144 of file GraphColoring.h.

Referenced by CalculateVertexColorClasses(), Clear(), and PrintVertexColorClasses().

Definition at line 146 of file GraphColoring.h.

Referenced by GetSeedMatrix(), Seed_init(), and Seed_reset().