ColPack
|
00001 // An example for using BipartiteGraphPartialColoringInterface 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 BipartiteGraphPartialColoringInterface *g = new BipartiteGraphPartialColoringInterface(SRC_FILE, s_InputFile.c_str(), "AUTO_DETECTED"); 00042 00043 //Do Partial-Distance-Two-Coloring the bipartite graph with the specified ordering 00044 g->PartialDistanceTwoColoring("SMALLEST_LAST", "ROW_PARTIAL_DISTANCE_TWO"); 00045 00046 /*Done with coloring. Below are possible things that you may 00047 want to do after coloring: 00048 //*/ 00049 00050 /* 1. Check Partial Distance Two Coloring result 00051 cout<<"Check Partial Distance Two coloring result ... "<<endl; 00052 if(g->CheckPartialDistanceTwoColoring() == _FALSE) cout<<" FAILED"<<endl; 00053 else cout<<" SUCCEEDED"<<endl; 00054 Pause(); 00055 //*/ 00056 00057 //* 2. Print coloring results 00058 g->PrintPartialColoringMetrics(); 00059 Pause(); 00060 //*/ 00061 00062 //* 3. Get the list of colorID of colored vertices (in this case, the left side of the bipartite graph) 00063 vector<int> vi_VertexPartialColors; 00064 g->GetVertexPartialColors(vi_VertexPartialColors); 00065 00066 //Print Partial Colors 00067 g->PrintPartialColors(); 00068 Pause(); 00069 //*/ 00070 00071 /* 4. Get seed matrix 00072 int i_SeedRowCount = 0; 00073 int i_SeedColumnCount = 0; 00074 double** Seed = g->GetSeedMatrix(&i_SeedRowCount, &i_SeedColumnCount); 00075 00076 //Display Seed 00077 printf("Seed matrix %d x %d \n", i_SeedRowCount, i_SeedColumnCount); 00078 displayMatrix(Seed, i_SeedRowCount, i_SeedColumnCount, 1); 00079 Pause(); 00080 //*/ 00081 00082 delete g; 00083 return 0; 00084 } 00085 //*/