ColPack
|
00001 // An example for using BipartiteGraphBicoloringInterface to color Bipartite Graph 00002 /* 00003 How to compile this driver manually: 00004 Please make sure that "baseDir" point to the directory (folder) containing the input matrix file, and 00005 s_InputFile should point to the input file that you want to use 00006 To compile the code, replace the Main.cpp file in Main directory with this file 00007 and run "make" in ColPack installation directory. Make will generate "ColPack.exe" executable 00008 Run "ColPack.exe" 00009 00010 Note: If you got "symbol lookup error ... undefined symbol " 00011 Please make sure that your LD_LIBRARY_PATH contains libColPack.so 00012 00013 Any time you have trouble understanding what a routine does, how to use a routine, or what are the accepted values for a parameter, 00014 please reference the COLPACK's online documentation (temporarily located at 00015 http://www.cscapes.org/dox/ColPack/html/ ). 00016 00017 For more information, please visit our webpage http://www.cscapes.org/coloringpage/ 00018 //*/ 00019 00020 #include "ColPackHeaders.h" 00021 00022 using namespace ColPack; 00023 using namespace std; 00024 00025 #ifndef TOP_DIR 00026 #define TOP_DIR "." 00027 #endif 00028 00029 // baseDir should point to the directory (folder) containing the input file 00030 string baseDir=TOP_DIR; 00031 00032 //* A SHORT VERSION 00033 int main(int argc, char ** argv) 00034 { 00035 // s_InputFile = baseDir + <name of the input file> 00036 string s_InputFile; //path of the input file 00037 s_InputFile = baseDir; 00038 s_InputFile += DIR_SEPARATOR; s_InputFile += "Graphs"; s_InputFile += DIR_SEPARATOR; s_InputFile += "column-compress.mtx"; 00039 00040 //Generate and color the bipartite graph 00041 BipartiteGraphBicoloringInterface *g = new BipartiteGraphBicoloringInterface(SRC_FILE, s_InputFile.c_str(), "AUTO_DETECTED"); 00042 00043 //Color the graph based on the specified ordering and (Star) Bicoloring 00044 g->Bicoloring( "SMALLEST_LAST", "IMPLICIT_COVERING__STAR_BICOLORING"); 00045 00046 /*Done with coloring. Below are possible things that you may 00047 want to do after coloring: 00048 //*/ 00049 00050 //* 1. Check Star Bicoloring Coloring result 00051 cout<<"Check Star Bicoloring Coloring result ... "<<endl; 00052 g->CheckStarBicoloring(); 00053 Pause(); 00054 //*/ 00055 00056 //* 2. Print coloring results 00057 g->PrintVertexBicoloringMetrics(); 00058 Pause(); 00059 //*/ 00060 00061 //* 3. Get the list of colorID of colored vertices (in this case, the left side of the bipartite graph) 00062 vector<int> vi_LeftVertexColors; 00063 g->GetLeftVertexColors(vi_LeftVertexColors); 00064 00065 vector<int> vi_RightVertexColors; 00066 g->GetRightVertexColors(vi_RightVertexColors); 00067 00068 //Print Partial Colors 00069 g->PrintVertexBicolors(); 00070 Pause(); 00071 //*/ 00072 00073 //* 4. Get seed matrix 00074 int i_LeftSeedRowCount = 0; 00075 int i_LeftSeedColumnCount = 0; 00076 double** LeftSeed = g->GetLeftSeedMatrix(&i_LeftSeedRowCount, &i_LeftSeedColumnCount); 00077 00078 int i_RightSeedRowCount = 0; 00079 int i_RightSeedColumnCount = 0; 00080 double** RightSeed = g->GetRightSeedMatrix(&i_RightSeedRowCount, &i_RightSeedColumnCount); 00081 00082 //Display Seeds 00083 if(i_LeftSeedRowCount>0 && i_LeftSeedColumnCount > 0){ 00084 printf("Left Seed matrix %d x %d \n", i_LeftSeedRowCount, i_LeftSeedColumnCount); 00085 displayMatrix(LeftSeed, i_LeftSeedRowCount, i_LeftSeedColumnCount, 1); 00086 Pause(); 00087 } 00088 00089 if(i_RightSeedRowCount>0 && i_RightSeedColumnCount > 0) { 00090 printf("Right Seed matrix %d x %d \n", i_RightSeedRowCount, i_RightSeedColumnCount); 00091 displayMatrix(RightSeed, i_RightSeedRowCount, i_RightSeedColumnCount, 1); 00092 Pause(); 00093 } 00094 //*/ 00095 00096 delete g; 00097 return 0; 00098 } 00099 //*/