pax_global_header 0000666 0000000 0000000 00000000064 12663561215 0014521 g ustar 00root root 0000000 0000000 52 comment=ffa4e4130011537bdc4658ebb78ab3088f0ea6dc
ColPack-1.0.10/ 0000775 0000000 0000000 00000000000 12663561215 0013114 5 ustar 00root root 0000000 0000000 ColPack-1.0.10/.gitignore 0000664 0000000 0000000 00000000502 12663561215 0015101 0 ustar 00root root 0000000 0000000 *.Plo
*.Po
*.a
*.exe
*.la
*.lai
*.lo
*.o
*.so
.deps/
.dirstamp
.libs/
.svn/
/ColPack
/INSTALL
/Makefile
/Makefile.in
/aclocal.m4
/ar-lib
/autom4te.cache/
/build
/compile
/config.guess
/config.h
/config.h.in
/config.log
/config.status
/config.sub
/configure
/depcomp
/install-sh
/libtool
/ltmain.sh
/m4/
/missing
/stamp-h1
ColPack-1.0.10/.travis.yml 0000664 0000000 0000000 00000000176 12663561215 0015231 0 ustar 00root root 0000000 0000000 language: cpp
compiler:
- gcc
- clang
before_script:
- autoreconf -fi
script:
- ./configure && make && make check
ColPack-1.0.10/AUTHORS 0000664 0000000 0000000 00000000172 12663561215 0014164 0 ustar 00root root 0000000 0000000 COLPACK
Copyright (C) 2005-2010 Assefaw H. Gebremedhin, Duc Nguyen, Arijit Tarafdar, Md. Mostofa Ali Patwary, Alex Pothen
ColPack-1.0.10/BipartiteGraphBicoloring/ 0000775 0000000 0000000 00000000000 12663561215 0020031 5 ustar 00root root 0000000 0000000 ColPack-1.0.10/BipartiteGraphBicoloring/BipartiteGraphBicoloring.cpp 0000664 0000000 0000000 00000441706 12663561215 0025466 0 ustar 00root root 0000000 0000000 /************************************************************************************
Copyright (C) 2005-2008 Assefaw H. Gebremedhin, Arijit Tarafdar, Duc Nguyen,
Alex Pothen
This file is part of ColPack.
ColPack is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ColPack is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with ColPack. If not, see .
************************************************************************************/
#include "ColPackHeaders.h"
using namespace std;
namespace ColPack
{
//Private Function 3501
void BipartiteGraphBicoloring::PresetCoveredVertexColors()
{
int i_LeftVertexCount = STEP_DOWN((signed) m_vi_LeftVertices.size());
int i_RightVertexCount = STEP_DOWN((signed) m_vi_RightVertices.size());
m_i_LeftVertexColorCount = m_i_RightVertexColorCount = m_i_VertexColorCount = _UNKNOWN;
m_vi_LeftVertexColors.clear();
m_vi_LeftVertexColors.resize((unsigned) i_LeftVertexCount, _FALSE);
m_vi_RightVertexColors.clear();
m_vi_RightVertexColors.resize((unsigned) i_RightVertexCount, _FALSE);
int i_CoveredLeftVertexCount = m_vi_CoveredLeftVertices.size();
int i_CoveredRightVertexCount = m_vi_CoveredRightVertices.size();
for(int i=0; i m_vi_LeftVertexColorFrequency[i])
{
m_i_SmallestLeftVertexColorClass = i;
m_i_SmallestLeftVertexColorClassSize = m_vi_LeftVertexColorFrequency[i];
}
}
m_vi_RightVertexColorFrequency.clear();
m_vi_RightVertexColorFrequency.resize((unsigned) m_i_RightVertexColorCount, _FALSE);
int i_RightVertexCount = STEP_DOWN((signed) m_vi_RightVertices.size());
for(int i = 0; i < i_RightVertexCount; i++)
{
m_vi_RightVertexColorFrequency[m_vi_RightVertexColors[i]]++;
}
for(int i = 0; i < m_i_RightVertexColorCount; i++)
{
if(m_i_LargestRightVertexColorClassSize < m_vi_RightVertexColorFrequency[i])
{
m_i_LargestRightVertexColorClass = i;
m_i_LargestRightVertexColorClassSize = m_vi_RightVertexColorFrequency[i];
}
if(m_i_SmallestRightVertexColorClassSize == _UNKNOWN)
{
m_i_SmallestRightVertexColorClass = i;
m_i_SmallestRightVertexColorClassSize = m_vi_RightVertexColorFrequency[i];
}
else
if(m_i_SmallestRightVertexColorClassSize > m_vi_RightVertexColorFrequency[i])
{
m_i_SmallestRightVertexColorClass = i;
m_i_SmallestRightVertexColorClassSize = m_vi_RightVertexColorFrequency[i];
}
}
m_i_LargestVertexColorClassSize = m_i_LargestLeftVertexColorClassSize>m_i_LargestRightVertexColorClassSize?m_i_LargestLeftVertexColorClassSize:m_i_LargestRightVertexColorClassSize;
m_i_LargestVertexColorClass = m_i_LargestVertexColorClassSize==m_i_LargestLeftVertexColorClassSize?m_i_LargestLeftVertexColorClass:m_i_LargestRightVertexColorClass;
m_i_SmallestVertexColorClassSize = m_i_SmallestLeftVertexColorClassSize vi_CandidateColors, vi_VertexColors;
int i_LeftVertexCount = STEP_DOWN((signed) m_vi_LeftVertices.size());
int i_RightVertexCount = STEP_DOWN((signed) m_vi_RightVertices.size());
int i_LeftVertexCoverSize = (signed) m_vi_CoveredLeftVertices.size();
int i_RightVertexCoverSize = (signed) m_vi_CoveredRightVertices.size();
m_i_VertexColorCount = STEP_UP(i_LeftVertexCoverSize) + STEP_UP(i_RightVertexCoverSize);
vi_VertexColors.clear();
vi_VertexColors.resize((unsigned) i_LeftVertexCount + i_RightVertexCount, _FALSE);
vi_CandidateColors.clear();
vi_CandidateColors.resize((unsigned) m_i_VertexColorCount, _UNKNOWN);
i_ColorViolationCount = _FALSE;
for(i=0; i0) {
free_2DMatrix(dp2_lSeed, i_lseed_rowCount);
}
else {
cerr<<"ERR: freeing left seed matrix with 0 row"<0) {
free_2DMatrix(dp2_rSeed, i_rseed_rowCount);
}
else {
cerr<<"ERR: freeing right seed matrix with 0 row"< vi_CandidateColors;
vector vi_EdgeStarMap, vi_LeftStarHubMap, vi_RightStarHubMap;
vector vi_FirstTreated;
vector vi_FirstNeighborOne, vi_FirstNeighborTwo;
i_LeftVertexCount = STEP_DOWN((signed) m_vi_LeftVertices.size());
i_RightVertexCount = STEP_DOWN((signed) m_vi_RightVertices.size());
i_LargerVertexCount = i_LeftVertexCount>i_RightVertexCount?i_LeftVertexCount:i_RightVertexCount;
i_EdgeCount = (signed) m_vi_Edges.size()/2;
vi_EdgeStarMap.clear();
vi_EdgeStarMap.resize((unsigned) i_EdgeCount, _UNKNOWN);
m_mimi2_VertexEdgeMap.clear();
k=_FALSE;
for(i=0; i _FALSE)
{
vi_CandidateColors[m_vi_LeftVertexColors[i_SecondNeighboringVertex]] = i_PresentVertex;
}
}
}
}
for(j=_TRUE; j vi_CandidateColors;
vector vi_EdgeStarMap, vi_LeftStarHubMap, vi_RightStarHubMap;
vector vi_FirstTreated;
vector vi_FirstNeighborOne, vi_FirstNeighborTwo;
i_LeftVertexCount = STEP_DOWN((signed) m_vi_LeftVertices.size());
i_RightVertexCount = STEP_DOWN((signed) m_vi_RightVertices.size());
i_LargerVertexCount = i_LeftVertexCount>i_RightVertexCount?i_LeftVertexCount:i_RightVertexCount;
i_EdgeCount = (signed) m_vi_Edges.size()/2;
vi_EdgeStarMap.clear();
vi_EdgeStarMap.resize((unsigned) i_EdgeCount, _UNKNOWN);
m_mimi2_VertexEdgeMap.clear();
k=_FALSE;
for(i=0; i _FALSE)
{
vi_CandidateColors[m_vi_RightVertexColors[i_SecondNeighboringVertex]] = i_PresentVertex;
}
}
}
}
for(j=_TRUE; j vi_CandidateColors;
vector vi_EdgeCodes;
i_LeftVertexCount = STEP_DOWN((signed) m_vi_LeftVertices.size());
i_RightVertexCount = STEP_DOWN((signed) m_vi_RightVertices.size());
i_EdgeCount = (signed) m_vi_Edges.size()/2;
m_mimi2_VertexEdgeMap.clear();
k=_FALSE;
for(i=0; i vi_CandidateColors;
vector vi_EdgeStarMap, vi_LeftStarHubMap, vi_RightStarHubMap;
vector vi_LeftTreated, vi_RightTreated;
vector vi_FirstNeighborOne, vi_FirstNeighborTwo;
i_LeftVertexCount = STEP_DOWN((signed) m_vi_LeftVertices.size());
i_RightVertexCount = STEP_DOWN((signed) m_vi_RightVertices.size());
i_EdgeCount = (signed) m_vi_Edges.size()/2;
vi_EdgeStarMap.clear();
vi_EdgeStarMap.resize((unsigned) i_EdgeCount, _UNKNOWN);
m_mimi2_VertexEdgeMap.clear();
k=_FALSE;
for(i=0; i vi_CandidateColors;
vector vi_EdgeStarMap, vi_LeftStarHubMap, vi_RightStarHubMap;
vector vi_LeftTreated, vi_RightTreated;
vector vi_FirstNeighborOne, vi_FirstNeighborTwo;
i_LeftVertexCount = STEP_DOWN((signed) m_vi_LeftVertices.size());
i_RightVertexCount = STEP_DOWN((signed) m_vi_RightVertices.size());
i_EdgeCount = (signed) m_vi_Edges.size()/2;
vi_EdgeStarMap.clear();
vi_EdgeStarMap.resize((unsigned) i_EdgeCount, _UNKNOWN);
m_mimi2_VertexEdgeMap.clear();
k=_FALSE;
for(i=0; i vi_IncludedEdges;
vector vi_CandidateColors;
vector vi_EdgeStarMap, vi_LeftStarHubMap, vi_RightStarHubMap;
vector vi_LeftTreated, vi_RightTreated;
vector vi_FirstNeighborOne, vi_FirstNeighborTwo;
i_LeftVertexCount = STEP_DOWN((signed) m_vi_LeftVertices.size());
i_RightVertexCount = STEP_DOWN((signed) m_vi_RightVertices.size());
i_EdgeCount = (signed) m_vi_Edges.size()/2;
vi_EdgeStarMap.clear();
vi_EdgeStarMap.resize((unsigned) i_EdgeCount, _UNKNOWN);
m_mimi2_VertexEdgeMap.clear();
i_IncludedEdgeCount =_FALSE;
for(i=0; i= i_EdgeCount)
{
break;
}
}
i_LeftVertexDefaultColor = _FALSE;
i_RightVertexDefaultColor = _FALSE;
for(i=0; i vi_IncludedEdges;
vector vi_CandidateColors;
vector vi_EdgeStarMap, vi_LeftStarHubMap, vi_RightStarHubMap;
vector vi_LeftTreated, vi_RightTreated;
vector vi_FirstNeighborOne, vi_FirstNeighborTwo;
i_LeftVertexCount = STEP_DOWN((signed) m_vi_LeftVertices.size());
i_RightVertexCount = STEP_DOWN((signed) m_vi_RightVertices.size());
i_EdgeCount = (signed) m_vi_Edges.size()/2;
vi_EdgeStarMap.clear();
vi_EdgeStarMap.resize((unsigned) i_EdgeCount, _UNKNOWN);
m_mimi2_VertexEdgeMap.clear();
i_IncludedEdgeCount =_FALSE;
for(i=0; i= i_EdgeCount)
{
break;
}
}
i_LeftVertexDefaultColor = _FALSE;
i_RightVertexDefaultColor = _FALSE;
for(i=0; i vi_IncludedEdges;
vector vi_CandidateColors;
vector vi_EdgeStarMap, vi_LeftStarHubMap, vi_RightStarHubMap;
vector vi_LeftTreated, vi_RightTreated;
vector vi_FirstNeighborOne, vi_FirstNeighborTwo;
i_LeftVertexCount = STEP_DOWN((signed) m_vi_LeftVertices.size());
i_RightVertexCount = STEP_DOWN((signed) m_vi_RightVertices.size());
i_EdgeCount = (signed) m_vi_Edges.size()/2;
vi_EdgeStarMap.clear();
vi_EdgeStarMap.resize((unsigned) i_EdgeCount, _UNKNOWN);
m_mimi2_VertexEdgeMap.clear();
i_IncludedEdgeCount =_FALSE;
for(i=0; i= i_EdgeCount)
{
break;
}
}
i_LeftVertexDefaultColor = _FALSE;
i_RightVertexDefaultColor = _FALSE;
for(i=0; i vi_CandidateColors;
vector vi_IncludedEdges;
i_LeftVertexCount = STEP_DOWN((signed) m_vi_LeftVertices.size());
i_RightVertexCount = STEP_DOWN((signed) m_vi_RightVertices.size());
i_EdgeCount = (signed) m_vi_Edges.size()/2;
m_mimi2_VertexEdgeMap.clear();
i_IncludedEdgeCount =_FALSE;
for(i=0; i= i_EdgeCount)
{
break;
}
}
i_LeftVertexDefaultColor = _FALSE;
i_RightVertexDefaultColor = _FALSE;
for(i=0; i vi_VertexColors;
i_LeftVertexCount = STEP_DOWN((signed) m_vi_LeftVertices.size());
i_RightVertexCount = STEP_DOWN((signed) m_vi_RightVertices.size());
i_MaximumColorCount = STEP_UP(i_LeftVertexCount) + STEP_UP(i_RightVertexCount);
vi_VertexColors.clear();
vi_VertexColors.resize((unsigned) i_MaximumColorCount, _FALSE);
i_ColorViolationCount = _FALSE;
for(i=0; i &output)
{
output = m_vi_LeftVertexColors;
}
//Public Function 3574
void BipartiteGraphBicoloring::GetRightVertexColors(vector &output)
{
output = m_vi_RightVertexColors;
}
void BipartiteGraphBicoloring::GetRightVertexColors_Transformed(vector &output)
{
int rowCount = GetRowVertexCount();
int columnCount = GetColumnVertexCount();
output = m_vi_RightVertexColors;
for (int i=0; i < output.size(); i++) {
output[i] -= rowCount;
if (output[i] == columnCount + 1) output[i] = 0; //color 0, the rows with this color should be ignored.
}
}
//Public Function 3575
void BipartiteGraphBicoloring::PrintVertexBicolorClasses()
{
if(CalculateVertexColorClasses() != _TRUE)
{
cout<(*ip1_SeedColumnCount)) {
printf("**WARNING: Out of bound: Seed[%d >= %d][%d] = 1. \n",m_vi_LeftVertexColors[i]-1,(*ip1_SeedColumnCount), i);
}
#endif
if(m_vi_LeftVertexColors[i] != 0) { //ignore color 0
Seed[m_vi_LeftVertexColors[i]-1][i] = 1.;
}
}
return Seed;
}
double** BipartiteGraphBicoloring::GetRightSeedMatrix_unmanaged(int* ip1_SeedRowCount, int* ip1_SeedColumnCount) {
int i_size = GetRightVertexCount();
vector RightVertexColors_Transformed;
GetRightVertexColors_Transformed(RightVertexColors_Transformed);
int i_num_of_colors = m_i_RightVertexColorCount;
if (i_RightVertexDefaultColor == 1) i_num_of_colors--; //color ID 0 is used, ignore it
(*ip1_SeedRowCount) = i_size;
(*ip1_SeedColumnCount) = i_num_of_colors;
if((*ip1_SeedRowCount) == 0 || (*ip1_SeedColumnCount) == 0) return NULL;
#if DEBUG != _UNKNOWN
printf("Seed[%d][%d] \n",(*ip1_SeedRowCount),(*ip1_SeedColumnCount));
#endif
// allocate and initialize Seed matrix
double** Seed = new double*[(*ip1_SeedRowCount)];
for (int i=0; i<(*ip1_SeedRowCount); i++) {
Seed[i] = new double[(*ip1_SeedColumnCount)];
for(int j=0; j<(*ip1_SeedColumnCount); j++) Seed[i][j]=0.;
}
// populate Seed matrix
for (int i=0; i < (*ip1_SeedRowCount); i++) {
#if DEBUG != _UNKNOWN
if(RightVertexColors_Transformed[i]>(*ip1_SeedRowCount)) {
printf("**WARNING: Out of bound: Seed[%d][%d >= %d] = 1. \n",i, RightVertexColors_Transformed[i] - 1, (*ip1_SeedRowCount));
}
#endif
if(RightVertexColors_Transformed[i] != 0) { //ignore color 0
Seed[i][RightVertexColors_Transformed[i] - 1] = 1.;
}
}
return Seed;
}
double BipartiteGraphBicoloring::GetVertexColoringTime() {
return m_d_ColoringTime;
}
void BipartiteGraphBicoloring::GetSeedMatrix(double*** dp3_LeftSeed, int* ip1_LeftSeedRowCount, int* ip1_LeftSeedColumnCount, double*** dp3_RightSeed, int* ip1_RightSeedRowCount, int* ip1_RightSeedColumnCount) {
(*dp3_LeftSeed) = GetLeftSeedMatrix(ip1_LeftSeedRowCount, ip1_LeftSeedColumnCount);
(*dp3_RightSeed) = GetRightSeedMatrix(ip1_RightSeedRowCount, ip1_RightSeedColumnCount);
}
void BipartiteGraphBicoloring::GetSeedMatrix_unmanaged(double*** dp3_LeftSeed, int* ip1_LeftSeedRowCount, int* ip1_LeftSeedColumnCount, double*** dp3_RightSeed, int* ip1_RightSeedRowCount, int* ip1_RightSeedColumnCount) {
(*dp3_LeftSeed) = GetLeftSeedMatrix_unmanaged(ip1_LeftSeedRowCount, ip1_LeftSeedColumnCount);
(*dp3_RightSeed) = GetRightSeedMatrix_unmanaged(ip1_RightSeedRowCount, ip1_RightSeedColumnCount);
}
}
ColPack-1.0.10/BipartiteGraphBicoloring/BipartiteGraphBicoloring.h 0000664 0000000 0000000 00000024230 12663561215 0025120 0 ustar 00root root 0000000 0000000 /************************************************************************************
Copyright (C) 2005-2008 Assefaw H. Gebremedhin, Arijit Tarafdar, Duc Nguyen,
Alex Pothen
This file is part of ColPack.
ColPack is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ColPack is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with ColPack. If not, see .
************************************************************************************/
using namespace std;
#ifndef BIPARTITEGRAPHBICOLORING_H
#define BIPARTITEGRAPHBICOLORING_H
namespace ColPack
{
/** @ingroup group22
* @brief class BipartiteGraphBicoloring in @link group22@endlink.
Bipartite graph bicoloring is an assignment of colors to subsets of column and row vertices
of the bipartite graph of a Jacobian matrix. The present version of ColPack provides methods for star
bicoloring only. The distance-one coloring constraint is satisfied by all bicoloring algorithms by selecting
colors for row and column vertices from two disjoint sets of colors. Sizes of the sets are equal to the number
of row and column vertices respectively, which are the maximum number of colors that can be required by
the row or column vertices.
In star bicoloring, vertex cover can be computed either explicitly or implicitly. An explicit
vertex cover is computed and used to determine which vertices are to be colored.
An implicit vertex cover is computed by including vertices as they get colored, into the cover and is used to
determine the end of coloring as a vertex cover is reached. In both cases pre-computed vertex ordering
determines the order in which vertices are colored. In implicit vertex cover, a vertex
is not selected as a candidate vertex to be colored if no edge is incident on the vertex which has not been
covered by any other colored vertex.
*/
class BipartiteGraphBicoloring : public BipartiteGraphOrdering
{
public: //DOCUMENTED
//Public Function 3573
/// Get the color IDs for the left vertices (rows). Color IDs start from 1, color ID 0 should be ignored
void GetLeftVertexColors(vector &output);
//Public Function 3574
/// Get the color IDs for the right vertices (columns). Color IDs start from (# of rows + 1), color ID (# of rows + # of columns + 1) should be ignored
void GetRightVertexColors(vector &output);
/// Get the color IDs for the right vertices (columns) in the format similar to GetLeftVertexColor(). Color IDs start from 1, color ID 0 should be ignored
void GetRightVertexColors_Transformed(vector &output);
///Generate and return the Left Seed matrix. This Seed matrix is managed and freed by ColPack
/**Precondition:
- the Graph has been Bicolored
Postcondition:
- Size of the returned matrix is (*ip1_SeedRowCount) rows x (*ip1_SeedColumnCount) columns.
(*ip1_SeedColumnCount) == num of rows of the original matrix == GetRowVertexCount()
(*ip1_SeedRowCount) == num of colors used to color the left (row) vertices excluding color 0.
Notes:
- Vertices with color 0 are ignored.
That also means left (row) vertices with color 1 will be grouped together
into the first row (row 0) of the seed matrix and so on.
*/
double** GetLeftSeedMatrix(int* ip1_SeedRowCount, int* ip1_SeedColumnCount);
/// Same as GetLeftSeedMatrix(), 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.
*/
double** GetLeftSeedMatrix_unmanaged(int* ip1_SeedRowCount, int* ip1_SeedColumnCount);
///Return the Right Seed matrix. This Seed matrix is managed and freed by ColPack
/** Precondition:
- the Graph has been Bicolored
Postcondition:
- Size of the returned matrix is (*ip1_SeedRowCount) rows x (*ip1_SeedColumnCount) columns.
(*ip1_SeedRowCount) == num of columns of the original matrix == GetColumnVertexCount()
(*ip1_SeedColumnCount) == num of colors used to color the right (column) vertices excluding color 0.
Notes:
- Vertices with color 0 are ignored.
That also means right (column) vertices with color 1 will be grouped together
into the first column (column 0) of the seed matrix and so on.
*/
double** GetRightSeedMatrix(int* ip1_SeedRowCount, int* ip1_SeedColumnCount);
/// Same as GetRightSeedMatrix(), 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.
*/
double** GetRightSeedMatrix_unmanaged(int* ip1_SeedRowCount, int* ip1_SeedColumnCount);
///Return both the Left and Right Seed matrix. These Seed matrices are managed and freed by ColPack
/** Notes:
- These Seed matrices are NOT managed by ColPack. Therefore, the user should free the Seed matrices manually when the matrices are no longer needed.
*/
void GetSeedMatrix(double*** dp3_LeftSeed, int* ip1_LeftSeedRowCount, int* ip1_LeftSeedColumnCount, double*** dp3_RightSeed, int* ip1_RightSeedRowCount, int* ip1_RightSeedColumnCount);
/// Same as GetSeedMatrix(), except that These Seed matrices are NOT managed by ColPack
/** Notes:
- These Seed matrices are NOT managed by ColPack. Therefore, the user should free the Seed matrices manually when the matrices are no longer needed.
*/
void GetSeedMatrix_unmanaged(double*** dp3_LeftSeed, int* ip1_LeftSeedRowCount, int* ip1_LeftSeedColumnCount, double*** dp3_RightSeed, int* ip1_RightSeedRowCount, int* ip1_RightSeedColumnCount);
protected: //DOCUMENTED
/// Whether or not color 0 is used for left vertices
/** i_LeftVertexDefaultColor ==
- 0 if color 0 is not used
- 1 if color 0 is used
//*/
int i_LeftVertexDefaultColor;
/// Whether or not color 0 is used for right vertices
/** i_RightVertexDefaultColor ==
- 0 if color 0 is not used
- 1 if color 0 is used
//*/
int i_RightVertexDefaultColor;
/// The number of colors used to color Left Vertices
/** Note: Color 0 is also counted if used.
If color 0 is used, i_LeftVertexDefaultColor will be set to 1.
//*/
int m_i_LeftVertexColorCount;
/// The number of colors used to color Right Vertices
/** Note: Color 0 (or actually (i_LeftVertexCount + i_RightVertexCount + 1)) is also counted if used.
If color 0 is used, i_RightVertexDefaultColor will be set to 1.
//*/
int m_i_RightVertexColorCount;
int m_i_VertexColorCount;
/// The color IDs used to color the left vertices (rows).
/** Note: Color IDs start from 1, color ID 0 should be ignored
//*/
vector m_vi_LeftVertexColors;
/// The color IDs used to color the right vertices (columns).
/** Note: Color IDs start from (# of rows + 1), color ID (# of rows + # of columns + 1), which is color 0, should be ignored
//*/
vector m_vi_RightVertexColors;
bool lseed_available;
int i_lseed_rowCount;
double** dp2_lSeed;
bool rseed_available;
int i_rseed_rowCount;
double** dp2_rSeed;
void Seed_init();
void Seed_reset();
private:
//Private Function 3501
void PresetCoveredVertexColors();
//Private Function 3506
int CheckVertexColoring(string s_VertexColoringVariant);
//Private Function 3507
int CalculateVertexColorClasses();
//Private Function 3508
int FixMinimalCoverStarBicoloring();
protected:
int m_i_ViolationCount;
//int m_i_ColoringUnits; // used in ImplicitCoveringAcyclicBicoloring()
int m_i_LargestLeftVertexColorClass;
int m_i_LargestRightVertexColorClass;
int m_i_LargestLeftVertexColorClassSize;
int m_i_LargestRightVertexColorClassSize;
int m_i_SmallestLeftVertexColorClass;
int m_i_SmallestRightVertexColorClass;
int m_i_SmallestLeftVertexColorClassSize;
int m_i_SmallestRightVertexColorClassSize;
int m_i_LargestVertexColorClass;
int m_i_SmallestVertexColorClass;
int m_i_LargestVertexColorClassSize;
int m_i_SmallestVertexColorClassSize;
double m_d_AverageLeftVertexColorClassSize;
double m_d_AverageRightVertexColorClassSize;
double m_d_AverageVertexColorClassSize;
double m_d_ColoringTime;
double m_d_CheckingTime;
string m_s_VertexColoringVariant;
vector m_vi_LeftVertexColorFrequency;
vector m_vi_RightVertexColorFrequency;
public:
//Public Constructor 3551
BipartiteGraphBicoloring();
//Public Destructor 3552
~BipartiteGraphBicoloring();
//Virtual Function 3553
virtual void Clear();
//Virtual Function 3554
virtual void Reset();
//Public Function 3562
int ImplicitCoveringStarBicoloring();
//Public Function 3560
int ExplicitCoveringStarBicoloring();
//Public Function 3559
int ExplicitCoveringModifiedStarBicoloring();
//Public Function 3564
int ImplicitCoveringGreedyStarBicoloring();
//Public Function 3556
int MinimalCoveringRowMajorStarBicoloring(); //????
//Public Function 3557
int MinimalCoveringColumnMajorStarBicoloring(); //????
//Public Function 3558
int ImplicitCoveringConservativeStarBicoloring(); // CRASH
//Public Function 3561
int MinimalCoveringStarBicoloring(); // CRASH
//Public Function 3563
int ImplicitCoveringRestrictedStarBicoloring(); // CRASH
//Public Function 3565
int CheckStarBicoloring();
//Public Function 3568
int GetLeftVertexColorCount();
//Public Function 3569
int GetRightVertexColorCount();
//Public Function 3570
int GetVertexColorCount();
//Public Function 3571
int GetViolationCount();
int GetRightVertexDefaultColor();
//Public Function 3572
string GetVertexBicoloringVariant();
string GetVertexColoringVariant();
//Public Function 3575
void PrintVertexBicolors();
//Public Function 3576
void PrintVertexBicoloringMetrics();
//Public Function 3577
void PrintVertexBicolorClasses();
double GetVertexColoringTime();
};
}
#endif
ColPack-1.0.10/BipartiteGraphBicoloring/BipartiteGraphBicoloringInterface.cpp 0000664 0000000 0000000 00000021132 12663561215 0027272 0 ustar 00root root 0000000 0000000 /************************************************************************************
Copyright (C) 2005-2008 Assefaw H. Gebremedhin, Arijit Tarafdar, Duc Nguyen,
Alex Pothen
This file is part of ColPack.
ColPack is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ColPack is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with ColPack. If not, see .
************************************************************************************/
#include "ColPackHeaders.h"
using namespace std;
namespace ColPack
{
//Public Destructor 3702
BipartiteGraphBicoloringInterface::~BipartiteGraphBicoloringInterface()
{
BipartiteGraphBicoloring::Clear();
Seed_reset();
}
//Virtual Function 3703
void BipartiteGraphBicoloringInterface::Clear()
{
BipartiteGraphBicoloring::Clear();
return;
}
//Virtual Function 3704
void BipartiteGraphBicoloringInterface::Reset()
{
BipartiteGraphBicoloring::Reset();
return;
}
void BipartiteGraphBicoloringInterface::GenerateSeedJacobian(double*** dp3_LeftSeed, int *ip1_LeftSeedRowCount, int *ip1_LeftSeedColumnCount, double*** dp3_RightSeed, int *ip1_RightSeedRowCount, int *ip1_RightSeedColumnCount, string s_OrderingVariant, string s_BicoloringVariant) {
//void BipartiteGraphBicoloringInterface::GenerateSeedJacobian(unsigned int ** uip2_JacobianSparsityPattern, int i_RowCount, int i_ColumnCount, double*** dp3_LeftSeed, int *ip1_LeftSeedRowCount, int *ip1_LeftSeedColumnCount, double*** dp3_RightSeed, int *ip1_RightSeedRowCount, int *ip1_RightSeedColumnCount, string s_OrderingVariant, string s_BicoloringVariant) {
//Clear (Re-initialize) the bipartite graph
//Clear();
//Read the sparsity pattern of the given Jacobian matrix (compressed sparse rows format)
//and create the corresponding bipartite graph
//BuildBPGraphFromRowCompressedFormat(uip2_JacobianSparsityPattern, i_RowCount, i_ColumnCount);
//Color the graph based on the specified ordering and (Star) Bicoloring
Bicoloring(s_OrderingVariant, s_BicoloringVariant);
//From the coloring information, create and return the Left and Right seed matrices
*dp3_LeftSeed = GetLeftSeedMatrix(ip1_LeftSeedRowCount, ip1_LeftSeedColumnCount);
*dp3_RightSeed = GetRightSeedMatrix(ip1_RightSeedRowCount, ip1_RightSeedColumnCount);
}
void BipartiteGraphBicoloringInterface::GenerateSeedJacobian_unmanaged(double*** dp3_LeftSeed, int *ip1_LeftSeedRowCount, int *ip1_LeftSeedColumnCount, double*** dp3_RightSeed, int *ip1_RightSeedRowCount, int *ip1_RightSeedColumnCount, string s_OrderingVariant, string s_BicoloringVariant) {
//Color the graph based on the specified ordering and (Star) Bicoloring
Bicoloring(s_OrderingVariant, s_BicoloringVariant);
//From the coloring information, create and return the Left and Right seed matrices
*dp3_LeftSeed = GetLeftSeedMatrix_unmanaged(ip1_LeftSeedRowCount, ip1_LeftSeedColumnCount);
*dp3_RightSeed = GetRightSeedMatrix_unmanaged(ip1_RightSeedRowCount, ip1_RightSeedColumnCount);
}
int BipartiteGraphBicoloringInterface::Bicoloring(string s_OrderingVariant, string s_BicoloringVariant) {
m_T_Timer.Start();
int i_OrderingStatus = OrderVertices(s_OrderingVariant);
m_T_Timer.Stop();
m_d_OrderingTime = m_T_Timer.GetWallTime();
if(i_OrderingStatus != _TRUE)
{
cerr< &output) {
BipartiteGraphOrdering::GetOrderedVertices(output);
}
}
ColPack-1.0.10/BipartiteGraphBicoloring/BipartiteGraphBicoloringInterface.h 0000664 0000000 0000000 00000017437 12663561215 0026754 0 ustar 00root root 0000000 0000000 /************************************************************************************
Copyright (C) 2005-2008 Assefaw H. Gebremedhin, Arijit Tarafdar, Duc Nguyen,
Alex Pothen
This file is part of ColPack.
ColPack is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ColPack is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with ColPack. If not, see .
************************************************************************************/
using namespace std;
#ifndef BIPARTITEGRAPHBICOLORINGINTERFACE_H
#define BIPARTITEGRAPHBICOLORINGINTERFACE_H
namespace ColPack
{
/** @ingroup group22
* @brief class BipartiteGraphBicoloringInterface in @link group22@endlink.
To be completed.
*/
class BipartiteGraphBicoloringInterface : public BipartiteGraphBicoloring
{
public: //DOCUMENTED
/// Build a BipartiteGraphBicoloringInterface object and create the bipartite graph based on the graph structure specified by the input source
/** This function will:
- 0. Create initial BipartiteGraphPartialColoringInterface object
- 1. Create the bipartite graph based on the graph structure specified by the input source
Structure of this variadic function's parameters: BipartiteGraphBicoloringInterface(int i_type, [2 or more parameters for input source depending on the value of i_type]). Here are some examples:
- Just create the BipartiteGraphBicoloringInterface object: BipartiteGraphBicoloringInterface(SRC_WAIT);
- Get the input from file: BipartiteGraphBicoloringInterface(SRC_FILE, s_InputFile.c_str() ,"AUTO_DETECTED");
- Get input from ADOLC: BipartiteGraphBicoloringInterface(SRC_MEM_ADOLC,uip2_SparsityPattern, i_rowCount, i_columnCount);
About input parameters:
- int i_type: specified the input source. i_type can be either:
- -1 (SRC_WAIT): only step 0 will be done.
- 0 (SRC_FILE): The graph structure will be read from file. The next 2 parameters are:
- char* fileName: name of the input file. If the full path is not given, the file is assumed to be in the current directory
- char* fileType can be either:
- "AUTO_DETECTED" or "". ColPack will decide the format of the file based on the file extension:
- ".mtx": MatrixMarket format
- ".hb", or any combination of ".": HarwellBoeing format
- ".graph": MeTiS format
- ".gen": Generic Matrix format
- ".gens": Generic Square Matrix format
- If the above extensions are not found, MatrixMarket format will be assumed.
- "MM" for MatrixMarket format (http://math.nist.gov/MatrixMarket/formats.html#MMformat). Notes:
- ColPack only accepts MatrixMarket coordinate format (NO array format)
- List of arithmetic fields accepted by ColPack: real, pattern or integer
- List of symmetry structures accepted by ColPack: general or symmetric
- The first line of the input file should be similar to this: "%%MatrixMarket matrix coordinate real general"
- "HB" for HarwellBoeing format (http://math.nist.gov/MatrixMarket/formats.html#hb)
- "MeTiS" for MeTiS format (http://people.sc.fsu.edu/~burkardt/data/metis_graph/metis_graph.html)
- "GEN" for Generic Matrix format
- "GENS" for Generic Square Matrix format
- 1 (SRC_MEM_ADOLC): The graph structure will be read from Row Compressed Structure (used by ADOLC). The next 3 parameters are:
- unsigned int **uip2_SparsityPattern: The pattern of Jacobian matrix stored in Row Compressed Format
- int i_rowCount: number of rows in the Jacobian matrix. Number of rows in uip2_SparsityPattern.
- int i_ColumnCount: number of columns in the Jacobian matrix. Number of columns in uip2_SparsityPattern.
- 2 (SRC_MEM_ADIC): TO BE IMPLEMENTED so that ColPack can interface with ADIC
//*/
BipartiteGraphBicoloringInterface(int i_type, ...);
/// Generate and return the Left and Right Seed matrices
/** This function will
- 1. Color the graph based on the specified ordering and (Star) Bicoloring
- 2. From the coloring information, create and return the Left (*dp3_LeftSeed[*ip1_RowColorCount][i_RowCount]) and Right (*dp3_RightSeed[i_ColumnCount][*ip1_ColumnColorCount]) seed matrices
About input parameters:
- s_OrderingVariant can be either
- "NATURAL" (default)
- "LARGEST_FIRST"
- "DYNAMIC_LARGEST_FIRST"
- "SMALLEST_LAST"
- "INCIDENCE_DEGREE"
- "RANDOM"
- s_BicoloringVariant can be either
- "IMPLICIT_COVERING__STAR_BICOLORING" (default)
- "EXPLICIT_COVERING__STAR_BICOLORING"
- "EXPLICIT_COVERING__MODIFIED_STAR_BICOLORING"
- "IMPLICIT_COVERING__GREEDY_STAR_BICOLORING"
Postcondition:
- *dp3_LeftSeed: the size will be:
- Row count (*ip1_LeftSeedRowCount): Row Color Count
- Column count (*ip1_LeftSeedColumnCount): Jacobian's Row Count
- *dp3_RightSeed: the size will be:
- Row count (*ip1_RightSeedRowCount): Jacobian's Column Count
- Column count (*ip1_RightSeedColumnCount): Column Color Count
*/
void GenerateSeedJacobian(double*** dp3_LeftSeed, int *ip1_LeftSeedRowCount, int *ip1_LeftSeedColumnCount, double*** dp3_RightSeed, int *ip1_RightSeedRowCount, int *ip1_RightSeedColumnCount, string s_OrderingVariant="NATURAL", string s_BicoloringVariant = "IMPLICIT_COVERING__STAR_BICOLORING");
/// Same as GenerateSeedJacobian(), except that these Seed matrices are NOT managed by ColPack
/** Notes:
- These Seed matrices are NOT managed by ColPack. Therefore, the user should free the Seed matrices manually when the matrices are no longer needed.
*/
void GenerateSeedJacobian_unmanaged(double*** dp3_LeftSeed, int *ip1_LeftSeedRowCount, int *ip1_LeftSeedColumnCount, double*** dp3_RightSeed, int *ip1_RightSeedRowCount, int *ip1_RightSeedColumnCount, string s_OrderingVariant="NATURAL", string s_BicoloringVariant = "IMPLICIT_COVERING__STAR_BICOLORING");
/// Bicolor the bipartite graph based on the requested s_BicoloringVariant and s_OrderingVariant
/** This function will
- 1. Order the vertices based on the requested Ordering variant (s_OrderingVariant)
- 2. Bicolor the graph based on the requested Bicoloring variant (s_BicoloringVariant)
- Ordering Time and Coloring Time will be recorded.
About input parameters:
- s_OrderingVariant can be either
- "NATURAL" (default)
- "LARGEST_FIRST"
- "DYNAMIC_LARGEST_FIRST"
- "SMALLEST_LAST"
- "INCIDENCE_DEGREE"
- "RANDOM"
- s_BicoloringVariant can be either
- "IMPLICIT_COVERING__STAR_BICOLORING" (default)
- "EXPLICIT_COVERING__STAR_BICOLORING"
- "EXPLICIT_COVERING__MODIFIED_STAR_BICOLORING"
- "IMPLICIT_COVERING__GREEDY_STAR_BICOLORING"
Postcondition:
- The Bipartite Graph is Bicolored, i.e., m_vi_LeftVertexColors and m_vi_RightVertexColors will be populated.
*/
int Bicoloring(string s_OrderingVariant = "NATURAL", string s_BicoloringVariant = "IMPLICIT_COVERING__STAR_BICOLORING");
///Return the Left Seed matrix
double** GetLeftSeedMatrix(int* ip1_LeftSeedRowCount, int* ip1_LeftSeedColumnCount);
///Return the Right Seed matrix
double** GetRightSeedMatrix(int* ip1_RightSeedRowCount, int* ip1_RightSeedColumnCount);
void GetOrderedVertices(vector &output);
private:
Timer m_T_Timer;
public:
//Public Destructor 3702
~BipartiteGraphBicoloringInterface();
//Virtual Function 3703
virtual void Clear();
//Virtual Function 3704
virtual void Reset();
};
}
#endif
ColPack-1.0.10/BipartiteGraphBicoloring/BipartiteGraphCore.cpp 0000664 0000000 0000000 00000014126 12663561215 0024257 0 ustar 00root root 0000000 0000000 /************************************************************************************
Copyright (C) 2005-2008 Assefaw H. Gebremedhin, Arijit Tarafdar, Duc Nguyen,
Alex Pothen
This file is part of ColPack.
ColPack is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ColPack is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with ColPack. If not, see .
************************************************************************************/
#include "ColPackHeaders.h"
using namespace std;
namespace ColPack
{
//Virtual Function 2102:3102
void BipartiteGraphCore::Clear()
{
m_i_MaximumLeftVertexDegree = _UNKNOWN;
m_i_MaximumRightVertexDegree = _UNKNOWN;
m_i_MaximumVertexDegree = _UNKNOWN;
m_i_MinimumLeftVertexDegree = _UNKNOWN;
m_i_MinimumRightVertexDegree = _UNKNOWN;
m_i_MinimumVertexDegree = _UNKNOWN;
m_d_AverageLeftVertexDegree = _UNKNOWN;
m_d_AverageRightVertexDegree = _UNKNOWN;
m_d_AverageVertexDegree = _UNKNOWN;
m_s_InputFile.clear();
m_vi_LeftVertices.clear();
m_vi_RightVertices.clear();
m_vi_Edges.clear();
m_mimi2_VertexEdgeMap.clear();
}
//Public Function 2103:3103
string BipartiteGraphCore::GetInputFile()
{
return(m_s_InputFile);
}
vector* BipartiteGraphCore::GetLeftVerticesPtr()
{
return &m_vi_LeftVertices;
}
vector* BipartiteGraphCore::GetRightVerticesPtr()
{
return &m_vi_RightVertices;
}
//Public Function 2104:3104
void BipartiteGraphCore::GetRowVertices(vector &output) const
{
output = (m_vi_LeftVertices);
}
unsigned int BipartiteGraphCore::GetRowVertices(unsigned int** ip2_RowVertex)
{
(*ip2_RowVertex) = (unsigned int*) malloc(m_vi_LeftVertices.size() * sizeof(unsigned int));
for(unsigned int i=0; i < m_vi_LeftVertices.size(); i++) {
(*ip2_RowVertex)[i] = m_vi_LeftVertices[i];
}
return m_vi_LeftVertices.size();
}
unsigned int BipartiteGraphCore::GetColumnIndices(unsigned int** ip2_ColumnIndex)
{
unsigned int ui_UpperBound = m_vi_LeftVertices[m_vi_LeftVertices.size() - 1];
(*ip2_ColumnIndex) = (unsigned int*) malloc(ui_UpperBound * sizeof(unsigned int));
for(unsigned int i=0; i < ui_UpperBound; i++) {
(*ip2_ColumnIndex)[i] = m_vi_Edges[i];
}
return ui_UpperBound;
}
void BipartiteGraphCore::GetLeftVertices(vector &output) const
{
output = (m_vi_LeftVertices);
}
//Public Function 2105:3105
void BipartiteGraphCore::GetColumnVertices(vector &output) const
{
output = (m_vi_RightVertices);
}
void BipartiteGraphCore::GetRightVertices(vector &output) const
{
output = (m_vi_RightVertices);
}
//Public Function 2106:3106
void BipartiteGraphCore::GetEdges(vector &output) const
{
output = (m_vi_Edges);
}
//Public Function 2107:3107
void BipartiteGraphCore::GetVertexEdgeMap(map< int, map > &output)
{
output = (m_mimi2_VertexEdgeMap);
}
//Public Function 2108:3108
int BipartiteGraphCore::GetRowVertexCount()
{
return(STEP_DOWN(m_vi_LeftVertices.size()));
}
int BipartiteGraphCore::GetLeftVertexCount()
{
return(STEP_DOWN(m_vi_LeftVertices.size()));
}
//Public Function 2109:3109
int BipartiteGraphCore::GetColumnVertexCount()
{
return(STEP_DOWN(m_vi_RightVertices.size()));
}
int BipartiteGraphCore::GetRightVertexCount()
{
return(STEP_DOWN(m_vi_RightVertices.size()));
}
//Public Function 2110:3110
int BipartiteGraphCore::GetEdgeCount()
{
return(m_vi_Edges.size()/2);
}
//Public Function 2111:3111
int BipartiteGraphCore::GetMaximumRowVertexDegree()
{
return(m_i_MaximumLeftVertexDegree);
}
//Public Function 2112:3112
int BipartiteGraphCore::GetMaximumColumnVertexDegree()
{
return(m_i_MaximumRightVertexDegree);
}
//Public Function 2113:3113
int BipartiteGraphCore::GetMaximumVertexDegree()
{
return(m_i_MaximumVertexDegree);
}
//Public Function 2114:3114
int BipartiteGraphCore::GetMinimumRowVertexDegree()
{
return(m_i_MinimumLeftVertexDegree);
}
//Public Function 2115:3115
int BipartiteGraphCore::GetMinimumColumnVertexDegree()
{
return(m_i_MinimumRightVertexDegree);
}
//Public Function 2116:3116
int BipartiteGraphCore::GetMinimumVertexDegree()
{
return(m_i_MinimumVertexDegree);
}
//Public Function 2117:3117
double BipartiteGraphCore::GetAverageRowVertexDegree()
{
return(m_d_AverageLeftVertexDegree);
}
//Public Function 2118:3118
double BipartiteGraphCore::GetAverageColumnVertexDegree()
{
return(m_d_AverageRightVertexDegree);
}
//Public Function 2119:3119
double BipartiteGraphCore::GetAverageVertexDegree()
{
return(m_d_AverageVertexDegree);
}
bool BipartiteGraphCore::operator==(const BipartiteGraphCore &other) const {
// Check for self-assignment!
if (this == &other) // Same object?
return true; // Yes, so the 2 objects are equal
//Compare vector m_vi_LeftVertices; vector m_vi_RightVertices; vector m_vi_Edges;
vector other_LeftVertices, other_RightVertices, other_Edges;
other.GetLeftVertices(other_LeftVertices);
other.GetRightVertices(other_RightVertices);
other.GetEdges(other_Edges);
/*
if(m_vi_LeftVertices==other_LeftVertices) cout<<"m_vi_LeftVertices==other_LeftVertices"<