├── .gitignore ├── .travis.yml ├── AUTHORS ├── ChangeLog ├── Examples ├── ColPackAll │ ├── Main.cpp │ └── Makefile ├── GeneralColoring │ ├── Main.cpp │ └── Makefile ├── README.md ├── SMPGC │ ├── Makefile │ └── main.cpp ├── SampleDrivers │ ├── .gitignore │ ├── Basic │ │ ├── Generate_seed_matrix_for_Hessian.cpp │ │ ├── Generate_seed_matrix_for_Jacobian.cpp │ │ ├── color_bipartite_graph_using_BipartiteGraphBicoloringInterface.cpp │ │ ├── color_bipartite_graph_using_BipartiteGraphPartialColoringInterface.cpp │ │ └── color_graph_using_GraphColoringInterface.cpp │ └── Matrix_Compression_and_Recovery │ │ ├── ADIC │ │ └── 01_Column_compression_and_recovery_for_Jacobian_return_ADIC_Format.cpp │ │ ├── ADOL-C │ │ ├── 01_Column_compression_and_recovery_for_Jacobian_return_Row_Compressed_Format.cpp │ │ ├── 02_Column_compression_and_recovery_for_Jacobian_return_Coordinate_Format.cpp │ │ ├── 03_Column_compression_and_recovery_for_Jacobian_return_Sparse_Solvers_Format.cpp │ │ ├── 04_Row_compression_and_recovery_for_Jacobian_return_Row_Compressed_Format.cpp │ │ ├── 05_Compression_and_direct_recovery_for_Hessian_return_Row_Compressed_Format.cpp │ │ ├── 06_Compression_and_direct_recovery_for_Hessian_return_Coordinate_Format.cpp │ │ ├── 07_Compression_and_direct_recovery_for_Hessian_return_Sparse_Solvers_Format.cpp │ │ ├── 08_Compression_and_indirect_recovery_for_Hessian_return_Row_Compressed_Format.cpp │ │ ├── 09_Bidirectional_compression_and_recovery_for_Jacobian_return_Row_Compressed_Format.cpp │ │ ├── 10_Column_compression_and_recovery_for_Jacobian_return_Row_Compressed_Format__unmanaged_usermem.cpp │ │ ├── 11_Compression_and_direct_recovery_for_Hessian_return_Row_Compressed_Format__unmanaged_usermem.cpp │ │ └── 12_Bidirectional_compression_and_recovery_for_Jacobian_return_Row_Compressed_Format__unmanaged_usermem.cpp │ │ ├── CSR_input │ │ └── 01_Column_compression_and_recovery_for_Jacobian_CSR_input_return_Row_Compressed_Format.cpp │ │ └── SMB │ │ ├── Makefile │ │ ├── README │ │ ├── eval_fun_chem.c │ │ ├── jac_full.mtx │ │ ├── jac_recovered.mtx │ │ ├── legend.txt │ │ └── sparse_jac_hess.cpp ├── SomeExample │ └── Main.cpp └── Use_Library │ ├── Makefile │ ├── README.md │ └── template.cpp ├── Graphs ├── bcsstk01.gif ├── bcsstk01.mtx ├── bcsstk01.rsa ├── bcsstk01_mod.mtx ├── bcsstm01.gif ├── bcsstm01.mtx ├── bcsstm01.rsa ├── column-compress.jpg ├── column-compress.mtx ├── hess_pat.jpg ├── hess_pat.mtx ├── hess_pat_small.jpg ├── hess_pat_small.mtx ├── jac_pat.jpg ├── jac_pat.mtx ├── mtx-spear-head.jpg ├── mtx-spear-head.mtx ├── mymatrix.jpg ├── mymatrix.mtx ├── mymatrix1.jpg ├── mymatrix1.mtx ├── row-compress.jpg └── row-compress.mtx ├── LICENSE ├── README.md ├── build ├── automake │ ├── Makefile.am │ └── configure.ac └── cmake │ ├── CMakeLists.txt │ └── ColPackConfig.cmake.in ├── goingToBeRemoved ├── COPYING ├── COPYING.LESSER ├── NEWS ├── autoconf.sh ├── main_page.txt └── previous_license_head ├── inc ├── ColPackHeaders.h └── Definitions.h └── src ├── BipartiteGraphBicoloring ├── BipartiteGraphBicoloring.cpp ├── BipartiteGraphBicoloring.h ├── BipartiteGraphBicoloringInterface.cpp ├── BipartiteGraphBicoloringInterface.h ├── BipartiteGraphCore.cpp ├── BipartiteGraphCore.h ├── BipartiteGraphInputOutput.cpp ├── BipartiteGraphInputOutput.h ├── BipartiteGraphOrdering.cpp ├── BipartiteGraphOrdering.h ├── BipartiteGraphVertexCover.cpp └── BipartiteGraphVertexCover.h ├── BipartiteGraphPartialColoring ├── BipartiteGraphPartialColoring.cpp ├── BipartiteGraphPartialColoring.h ├── BipartiteGraphPartialColoringInterface.cpp ├── BipartiteGraphPartialColoringInterface.h ├── BipartiteGraphPartialOrdering.cpp └── BipartiteGraphPartialOrdering.h ├── GeneralGraphColoring ├── GraphColoring.cpp ├── GraphColoring.h ├── GraphColoringInterface.cpp ├── GraphColoringInterface.h ├── GraphCore.cpp ├── GraphCore.h ├── GraphInputOutput.cpp ├── GraphInputOutput.h ├── GraphOrdering.cpp └── GraphOrdering.h ├── Recovery ├── HessianRecovery.cpp ├── HessianRecovery.h ├── JacobianRecovery1D.cpp ├── JacobianRecovery1D.h ├── JacobianRecovery2D.cpp ├── JacobianRecovery2D.h ├── RecoveryCore.cpp └── RecoveryCore.h ├── SMPGC ├── SMPGC.cpp ├── SMPGC.h ├── SMPGCColoring.cpp ├── SMPGCColoring.h ├── SMPGCColoringD1.cpp ├── SMPGCColoringD1BIT.cpp ├── SMPGCColoringD1Orig.cpp ├── SMPGCColoringD2.cpp ├── SMPGCColoringHybrid.cpp ├── SMPGCGraph.cpp ├── SMPGCGraph.h ├── SMPGCOrdering.cpp └── SMPGCOrdering.h └── Utilities ├── CoutLock.cpp ├── CoutLock.h ├── DisjointSets.cpp ├── DisjointSets.h ├── File.cpp ├── File.h ├── MatrixDeallocation.cpp ├── MatrixDeallocation.h ├── Pause.cpp ├── Pause.h ├── StringTokenizer.cpp ├── StringTokenizer.h ├── Timer.cpp ├── Timer.h ├── command_line_parameter_processor.cpp ├── command_line_parameter_processor.h ├── current_time.cpp ├── current_time.h ├── extra.cpp ├── extra.h ├── mmio.cpp ├── mmio.h ├── stat.cpp └── stat.h /.gitignore: -------------------------------------------------------------------------------- 1 | misc 2 | ColPack 3 | *.Plo 4 | *.Po 5 | *.a 6 | *.exe 7 | *.la 8 | *.lai 9 | *.lo 10 | *.o 11 | *.so 12 | .deps/ 13 | .dirstamp 14 | .libs/ 15 | .svn/ 16 | /ColPack 17 | /INSTALL 18 | /Makefile 19 | /Makefile.in 20 | /aclocal.m4 21 | /ar-lib 22 | /autom4te.cache/ 23 | /build 24 | /compile 25 | /config.guess 26 | /config.h 27 | /config.h.in 28 | /config.log 29 | /config.status 30 | /config.sub 31 | /configure 32 | /depcomp 33 | /install-sh 34 | /libtool 35 | /ltmain.sh 36 | /m4/ 37 | /missing 38 | /stamp-h1 39 | config.h.in~ 40 | lib/ 41 | test-driver 42 | cmake 43 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | compiler: g++-4.9 3 | 4 | 5 | matrix: 6 | include: 7 | - env: 8 | - MATRIX_EVAL="CC=clang && CXX=clang++ && CXX_FLAG-fopenmp=libomp" 9 | - env: 10 | - MATRIX_EVAL="CC=gcc && CXX=g++ && CXX_FLAG-fopenmp=libomp" 11 | 12 | 13 | 14 | #addons: 15 | # apt: 16 | # sources: 17 | # - george-edison55-precise-backports 18 | # packages: 19 | # - cmake-data 20 | # - cmake 21 | # 22 | #addons: 23 | # apt: 24 | # sources: 25 | # - ubuntu-toolchain-r-test 26 | # packages: 27 | # - gcc-4.9 28 | # - g++-4.9 29 | 30 | #before_script: 31 | # - autoreconf -fi 32 | 33 | script: 34 | - # try automake #./configure && make && make check 35 | - cd build/automake 36 | - autoreconf -vif 37 | - mkdir mywork 38 | - cd mywork 39 | - fullpath=$(pwd) # modify fullpath to your destination folder if need 40 | - ./configure --prefix=${fullpath} 41 | - make -j 4 # Where "4" is the number of cores on your machine 42 | - make install # install lib and include/ColPack to destination 43 | 44 | script: 45 | - # Now try building with CMake. 46 | - cd build/cmake 47 | - mkdir mywork 48 | - cd mywork 49 | - fullpath=$(pwd) 50 | - cmake .. -DCMAKE_INSTALL_PREFIX:PATH=${fullpath} 51 | - make #; ctest 52 | - make install 53 | 54 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | COLPACK 2 | Copyright (C) 2005-2010 Assefaw H. Gebremedhin, Duc Nguyen, Arijit Tarafdar, Md. Mostofa Ali Patwary, Alex Pothen 3 | 4 | The following people also help COLPACK works better 5 | 6 | Mu Wang 7 | 8 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | 2011-09-01 Duc Nguyen 2 | displayGraph() is updated to accept BipartiteGraphPartialColoringInterface &g 3 | At this point, displayGraph(BipartiteGraphPartialColoringInterface &g) cannot highlight coloring conflicts yet 4 | 2011-09-01 Duc Nguyen 5 | Add "int displayGraph(ColPack::GraphColoring &g);" in extra.cpp to support debugging 6 | this function will create the DOT-file that describe the graph (with or without color) , and then utilize GraphViz to display the graph in image. 7 | In the case of Star Coloring, if there are conflict(s), the conflict(s) will be highlighted in bold edges. 8 | Each node in the graph will have name in this form "v#_c#" (vertex ID follow by color ID (0-based indexing)) 9 | 2011-03-22 Duc Nguyen 10 | Version 1.0.3 11 | Fixed HessianRecovery::IndirectRecover_CoordinateFormat_vectors() bug that cause ColPack to crash 12 | PROBLEM: vd_IncludedVertices[] is used to keep both the values stored at the vertices and to mark that a vertex is no longer a part of the tree 13 | by setting vd_IncludedVertices[] = _UNKNOWN (-1) => ColPack crashed when some of the recovered values are -1 14 | SOLUTION: use a separate array vb_IncludedVertices[] to mark that a vertex is no longer a part of the tree 15 | Support for "make -j EXTRA_FLAGS=-D_COLPACK_CHECKPOINT_" are added for Bug Report purpose 16 | If you use ColPack indirrectly via another tool like ADIC or ADOL-C, you can generate the graph by 17 | running "make clean && make -j EXTRA_FLAGS=-D_COLPACK_CHECKPOINT_". When the program is executed, 18 | ColPack library will generate a Matrix Market format file ColPack_input_graph.mtx in the same directory as the running program. 19 | If this does not work, you can also force ColPack to generate the file by calling g->WriteMatrixMarket() 20 | with g is a GraphColoringInterface, BipartiteGraphPartialColoringInterface, or BipartiteGraphBicoloringInterface object 21 | Interface functions for ADIC partially developed 22 | BipartiteGraphPartialColoringInterface() now accepts input from ADIC (int i_type=SRC_MEM_ADIC) 23 | BipartiteGraphPartialColoringInterface(int i_type, std::list >* valsetlist, int rowCount) 24 | a bipartite graph can be built by calling: 25 | BipartiteGraphPartialColoringInterface *g = new BipartiteGraphPartialColoringInterface(SRC_MEM_ADIC, &valsetlist, rowCount); 26 | add int JacobianRecovery1D::RecoverD2Cln_ADICFormat( 27 | BipartiteGraphPartialColoringInterface* g, 28 | double** dp2_CompressedMatrix, 29 | std::list >& lsi_SparsityPattern, 30 | std::list > &lvd_NewValue) -------------------------------------------------------------------------------- /Examples/ColPackAll/Makefile: -------------------------------------------------------------------------------- 1 | # makefile for non-installed user 2 | # author: xin cheng 3 | # usage: change the following variable COLPACK_ROOT accordingly 4 | # delete OMP_FLAG=-fopenmp in MAC OS system 5 | COLPACK_ROOT = ../.. 6 | COLPACK_SRC = $(wildcard ${COLPACK_ROOT}/src/GeneralGraphColoring/*.cpp) 7 | COLPACK_SRC+= $(wildcard ${COLPACK_ROOT}/src/Utilities/*.cpp) 8 | COLPACK_SRC+= $(wildcard ${COLPACK_ROOT}/src/BipartiteGraphBicoloring/*.cpp) 9 | COLPACK_SRC+= $(wildcard ${COLPACK_ROOT}/src/BipartiteGraphPartialColoring/*.cpp) 10 | COLPACK_SRC+= $(wildcard ${COLPACK_ROOT}/src/SMPGC/*.cpp) 11 | COLPACK_SRC+= $(wildcard ${COLPACK_ROOT}/src/PartialD2SMPGC/*.cpp) 12 | 13 | COLPACK_OBJ = $(COLPACK_SRC:%.cpp=%.o) 14 | SRC = $(wildcard *.cpp) 15 | OBJ = $(SRC:%.cpp=%.o) $(COLPACK_OBJ) 16 | EXE = ColPack 17 | 18 | 19 | # compiler 20 | COMPILER = g++ # gnu 21 | OMP_FLAG = -fopenmp 22 | 23 | #COMPILER = icc # intel(R) 24 | #OMP_FLAG = -openmp 25 | 26 | # compile flags 27 | CCFLAGS = -Wall -std=c++11 $(OMP_FLAG) -Ofast #-O3 28 | # link flags 29 | LDFLAGS = -Wall -std=c++11 $(OMP_FLAG) -Ofast #-O3 30 | 31 | 32 | INCLUDES = -I./ 33 | INCLUDES = -I${COLPACK_ROOT}/inc 34 | INCLUDES+= -I${COLPACK_ROOT}/src/GeneralGraphColoring 35 | INCLUDES+= -I${COLPACK_ROOT}/src/BipartiteGraphBicoloring 36 | INCLUDES+= -I${COLPACK_ROOT}/src/BipartiteGraphPartialColoring 37 | INCLUDES+= -I${COLPACK_ROOT}/src/Utilities 38 | INCLUDES+= -I${COLPACK_ROOT}/src/Recovery 39 | INCLUDES+= -I${COLPACK_ROOT}/src/SMPGC 40 | INCLUDES+= -I${COLPACK_ROOT}/src/PartialD2SMPGC 41 | 42 | 43 | all: $(EXE) 44 | 45 | %.o : %.cpp 46 | $(COMPILER) $(INCLUDES) $(CCFLAGS) -c $< -o $@ 47 | 48 | $(EXE): $(OBJ) 49 | $(COMPILER) $^ $(INCLUDES) $(LDFLAGS) -o $@ 50 | 51 | clean: 52 | rm -f $(OBJ) $(EXE) 53 | 54 | -------------------------------------------------------------------------------- /Examples/GeneralColoring/Main.cpp: -------------------------------------------------------------------------------- 1 | #include "ColPackHeaders.h" 2 | #include 3 | #include 4 | using namespace ColPack; 5 | void usage(); 6 | 7 | int main(int argc, char* argv[]) { 8 | string fname; 9 | string order("LARGEST_FIRST"); 10 | string methd("DISTANCE_ONE"); 11 | bool bVerbose(false); 12 | unordered_set ParaD1Color={"DISTANCE_ONE_OMP"}; 13 | unordered_set BiColor={ 14 | "IMPLICIT_COVERING__STAR_BICOLORING", 15 | "EXPLICIT_COVERING__STAR_BICOLORING", 16 | "EXPLICIT_COVERING__MODIFIED_STAR_BICOLORING", 17 | "IMPLICIT_COVERING__GREEDY_STAR_BICOLORING" 18 | }; 19 | unordered_set PartialColor={ 20 | "COLUMN_PARTIAL_DISTANCE_TWO", 21 | "ROW_PARTIAL_DISTANCE_TWO" 22 | }; 23 | 24 | 25 | for(int i=1; iBicoloring(order.c_str(), methd.c_str()); 42 | if(bVerbose) fprintf(stdout, "number of colors: "); 43 | fprintf(stdout,"%d\n", p->GetVertexColorCount()); 44 | delete p; p=nullptr; 45 | } 46 | else if(PartialColor.count(methd)){ 47 | if(bVerbose) fprintf(stdout,"\ngraph: %s\norder: %s\nmethd: %s\nPartial Distantce Two Coloring\n",fname.c_str(), order.c_str(), methd.c_str()); 48 | BipartiteGraphPartialColoringInterface *p = new BipartiteGraphPartialColoringInterface(0, fname.c_str(), "AUTO_DETECTED"); 49 | p->PartialDistanceTwoColoring(order.c_str(), methd.c_str()); 50 | if(bVerbose) fprintf(stdout, "number of colors: "); 51 | fprintf(stdout,"%d\n", p->GetVertexColorCount()); 52 | delete p; p=nullptr; 53 | } 54 | else if(ParaD1Color.count(methd)){ 55 | if(bVerbose) fprintf(stdout,"\ngraph: %s\norder: %s\nmethd: %s\nShared Memory General Graph Coloring\n",fname.c_str(), order.c_str(), methd.c_str()); 56 | GraphColoringInterface *g = new GraphColoringInterface(SRC_FILE, fname.c_str(), "AUTO_DETECTED"); 57 | g->Coloring(order.c_str(), methd.c_str()); 58 | delete g; g=nullptr; 59 | } 60 | else{ 61 | if(bVerbose) fprintf(stdout,"\ngraph: %s\norder: %s\nmethd: %s\nGeneral Graph Coloring\n",fname.c_str(), order.c_str(), methd.c_str()); 62 | GraphColoringInterface *g = new GraphColoringInterface(SRC_FILE, fname.c_str(), "AUTO_DETECTED"); 63 | g->Coloring(order.c_str(), methd.c_str()); 64 | 65 | if(bVerbose) { 66 | double t1 = g->GetVertexOrderingTime(); 67 | double t2 = g->GetVertexColoringTime(); 68 | fprintf(stdout, "order+color time = %f = %f+%f\n",t1+t2, t1,t2); 69 | fprintf(stdout, "number of colors: "); 70 | fprintf(stdout,"%d\n",g->GetVertexColorCount()); 71 | } 72 | else { 73 | fprintf(stdout,"%d\n",g->GetVertexColorCount()); 74 | } 75 | delete g; g=nullptr; 76 | } 77 | if(bVerbose) fprintf(stdout,"\n"); 78 | return 0; 79 | } 80 | 81 | void usage(){ 82 | fprintf(stderr, "\nusage: ./ColPack -f -o -m [-v]\n" 83 | "-f : Input file name\n" 84 | "-o : LARGEST_FIRST\n" 85 | " SMALLEST_LAST,\n" 86 | " DYNAMIC_LARGEST_FIRST,\n" 87 | " INCIDENCE_DEGREE,\n" 88 | " NATURAL,\n" 89 | " RANDOM\n" 90 | "-m : DISTANCE_ONE\n" 91 | " ACYCLIC\n" 92 | " ACYCLIC_FOR_INDIRECT_RECOVERY\n" 93 | " STAR\n" 94 | " RESTRICTED_STAR\n" 95 | " DISTANCE_TWO\n" 96 | " --------------------\n" 97 | " IMPLICIT_COVERING__STAR_BICOLORING\n" 98 | " EXPLICIT_COVERING__STAR_BICOLORING\n" 99 | " EXPLICIT_COVERING__MODIFIED_STAR_BICOLORING\n" 100 | " IMPLICIT_COVERING__GREEDY_STAR_BICOLORING\n" 101 | " --------------------\n" 102 | " COLUMN_PARTIAL_DISTANCE_TWO\n" 103 | " ROW_PARTIAL_DISTANCE_TWO\n" 104 | "\n" 105 | "-v : verbose infomation\n" 106 | "\n" 107 | "\n" 108 | "Examples:\n" 109 | "./ColPack -f ../Graphs/bcsstk01.mtx -o LARGEST_FIRST -m DISTANCE_ONE -v\n" 110 | "./ColPack -f ../Graphs/bcsstk01.mtx -o SMALLEST_LAST -m ACYCLIC -v\n" 111 | "./ColPack -f ../Graphs/bcsstk01.mtx -o DYNAMIC_LARGEST_FIRST -m DISTANCE_ONE_OMP -v\n" 112 | "\n" 113 | ); 114 | } 115 | 116 | 117 | -------------------------------------------------------------------------------- /Examples/GeneralColoring/Makefile: -------------------------------------------------------------------------------- 1 | # makefile for non-installed user 2 | # author: xin cheng 3 | # usage: change the following variable COLPACK_ROOT accordingly 4 | # delete OMP_FLAG=-fopenmp in MAC OS system 5 | COLPACK_ROOT = ../.. 6 | COLPACK_SRC = $(wildcard ${COLPACK_ROOT}/src/GeneralGraphColoring/*.cpp) 7 | COLPACK_SRC+= $(wildcard ${COLPACK_ROOT}/src/Utilities/*.cpp) 8 | COLPACK_SRC+= $(wildcard ${COLPACK_ROOT}/src/BipartiteGraphBicoloring/*.cpp) 9 | COLPACK_SRC+= $(wildcard ${COLPACK_ROOT}/src/BipartiteGraphPartialColoring/*.cpp) 10 | COLPACK_SRC+= $(wildcard ${COLPACK_ROOT}/src/SMPGC/*.cpp) 11 | COLPACK_SRC+= $(wildcard ${COLPACK_ROOT}/src/PartialD2SMPGC/*.cpp) 12 | 13 | COLPACK_OBJ = $(COLPACK_SRC:%.cpp=%.o) 14 | SRC = $(wildcard *.cpp) 15 | OBJ = $(SRC:%.cpp=%.o) $(COLPACK_OBJ) 16 | EXE = ColPack 17 | 18 | 19 | # compiler 20 | COMPILER = g++ # gnu 21 | OMP_FLAG = -fopenmp 22 | 23 | #COMPILER = icc # intel(R) 24 | #OMP_FLAG = -openmp 25 | 26 | # compile flags 27 | CCFLAGS = -Wall -std=c++11 $(OMP_FLAG) -Ofast #-O3 28 | # link flags 29 | LDFLAGS = -Wall -std=c++11 $(OMP_FLAG) -Ofast #-O3 30 | 31 | 32 | INCLUDES = -I./ 33 | INCLUDES = -I${COLPACK_ROOT}/inc 34 | INCLUDES+= -I${COLPACK_ROOT}/src/GeneralGraphColoring 35 | INCLUDES+= -I${COLPACK_ROOT}/src/BipartiteGraphBicoloring 36 | INCLUDES+= -I${COLPACK_ROOT}/src/BipartiteGraphPartialColoring 37 | INCLUDES+= -I${COLPACK_ROOT}/src/Utilities 38 | INCLUDES+= -I${COLPACK_ROOT}/src/Recovery 39 | INCLUDES+= -I${COLPACK_ROOT}/src/SMPGC 40 | INCLUDES+= -I${COLPACK_ROOT}/src/PartialD2SMPGC 41 | 42 | 43 | all: $(EXE) 44 | 45 | %.o : %.cpp 46 | $(COMPILER) $(INCLUDES) $(CCFLAGS) -c $< -o $@ 47 | 48 | $(EXE): $(OBJ) 49 | $(COMPILER) $^ $(INCLUDES) $(LDFLAGS) -o $@ 50 | 51 | clean: 52 | rm -f $(OBJ) $(EXE) 53 | 54 | -------------------------------------------------------------------------------- /Examples/SMPGC/Makefile: -------------------------------------------------------------------------------- 1 | # makefile for non-installed user 2 | # author: xin cheng 3 | # usage: change the following variable COLPACK_ROOT accordingly 4 | # delete OMP_FLAG=-fopenmp in MAC OS system 5 | COLPACK_ROOT = ../.. 6 | COLPACK_SRC = $(wildcard ${COLPACK_ROOT}/src/GeneralGraphColoring/*.cpp) 7 | COLPACK_SRC+= $(wildcard ${COLPACK_ROOT}/src/Utilities/*.cpp) 8 | COLPACK_SRC+= $(wildcard ${COLPACK_ROOT}/src/BipartiteGraphBicoloring/*.cpp) 9 | COLPACK_SRC+= $(wildcard ${COLPACK_ROOT}/src/BipartiteGraphPartialColoring/*.cpp) 10 | COLPACK_SRC+= $(wildcard ${COLPACK_ROOT}/src/SMPGC/*.cpp) 11 | COLPACK_SRC+= $(wildcard ${COLPACK_ROOT}/src/PartialD2SMPGC/*.cpp) 12 | 13 | COLPACK_OBJ = $(COLPACK_SRC:%.cpp=%.o) 14 | SRC = $(wildcard *.cpp) 15 | OBJ = $(SRC:%.cpp=%.o) $(COLPACK_OBJ) 16 | EXE = ColPack 17 | 18 | 19 | # compiler 20 | COMPILER = g++ # gnu 21 | OMP_FLAG = -fopenmp 22 | 23 | #COMPILER = icc # intel(R) 24 | #OMP_FLAG = -openmp 25 | 26 | # compile flags 27 | CCFLAGS = -Wall -std=c++11 $(OMP_FLAG) -Ofast -m64 # -D DEBUG_JP_PROFILE #-D PRINT_DETAILED_STATS_#-O3 28 | # link flags 29 | LDFLAGS = -Wall -std=c++11 $(OMP_FLAG) -Ofast -m64 # -D DEBUG_JP_PROFILE #-O3 30 | 31 | 32 | INCLUDES = -I./ 33 | INCLUDES = -I${COLPACK_ROOT}/inc 34 | INCLUDES+= -I${COLPACK_ROOT}/src/GeneralGraphColoring 35 | INCLUDES+= -I${COLPACK_ROOT}/src/BipartiteGraphBicoloring 36 | INCLUDES+= -I${COLPACK_ROOT}/src/BipartiteGraphPartialColoring 37 | INCLUDES+= -I${COLPACK_ROOT}/src/Utilities 38 | INCLUDES+= -I${COLPACK_ROOT}/src/Recovery 39 | INCLUDES+= -I${COLPACK_ROOT}/src/SMPGC 40 | INCLUDES+= -I${COLPACK_ROOT}/src/PartialD2SMPGC 41 | 42 | 43 | all: $(EXE) 44 | 45 | %.o : %.cpp 46 | $(COMPILER) $(INCLUDES) $(CCFLAGS) -c $< -o $@ 47 | 48 | $(EXE): $(OBJ) 49 | $(COMPILER) $^ $(INCLUDES) $(LDFLAGS) -o $@ 50 | 51 | clean: 52 | rm -f $(OBJ) $(EXE) 53 | 54 | -------------------------------------------------------------------------------- /Examples/SMPGC/main.cpp: -------------------------------------------------------------------------------- 1 | #include "SMPGCColoring.h" 2 | #include 3 | using namespace ColPack; 4 | void usage(); 5 | 6 | 7 | int main(int argc, char* argv[]) { 8 | vector fnames; 9 | vector orders(1,"RANDOM"); 10 | vector methds(1,"D1_OMP_GM3P"); 11 | bool bVerbose(false); 12 | vector nTs(1); 13 | vector options(1,"GM3P"); 14 | vector switch_iters(1,0); 15 | vector pf_names(1,"."); 16 | int bCheck(0); 17 | 18 | for(int i=1; i60) { printf(" %d min",((int)iotime)/60); iotime= ((int)(iotime)%60)+(iotime- (int)(iotime)); } printf(" %g sec\n",iotime); 69 | } 70 | 71 | for(auto & o : orders){ 72 | g->global_ordering(o, bVerbose?(&ordtime):nullptr); 73 | if(bVerbose) { 74 | printf("global order %s ordtime",o.c_str()); if(ordtime>60) { printf(" %d min",((int)ordtime)/60); ordtime= ((int)(ordtime)%60)+(ordtime- (int)(ordtime)); } printf(" %g sec\n",ordtime); 75 | } 76 | 77 | for(auto& m : methds) { 78 | for(auto nT : nTs) 79 | for(auto switch_iter : switch_iters) 80 | g->Coloring(nT, m, switch_iter); 81 | }//end for methods 82 | }//end for orders 83 | delete g; 84 | }//end for files 85 | return 0; 86 | } 87 | 88 | void usage(){ 89 | fprintf(stderr, "\n\n\nUSAGE:\n $./ColPack -f -o -m [-v] --nT \n" 90 | "\n" 91 | "-f : Input file names\n" 92 | "-o : NATURAL\n" 93 | " RANDOM\n" 94 | " LARGEST_FIRST\n" 95 | " SMALLEST_LAST\n" 96 | "-m : D1_OMP_[_]\n" 97 | " D1_OMP_HB[MT]JP_[_]\n" 98 | " D2_OMP_[_]\n" 99 | "\n" 100 | "-nT : list of number threads, --nT is also accept.\n" 101 | "-v : verbose for debug infomation\n" 102 | "(only for HYBRID METHOD)\n" 103 | " -sit \n" 104 | "\n" 105 | "List of Method:\n" 106 | " D1_OMP_GM3P D1_OMP_GM3P_LF D1_OMP_GM3P_.. \n" 107 | " D1_OMP_GMMP D1_OMP_GMMP_LF D1_OMP_GMMP_.. \n" 108 | " D1_OMP_SERIAL D1_OMP_SERIAL_LF D1_OMP_SERIAL_..\n" 109 | " D1_OMP_JP D1_OMP_JP_LF D1_OMP_JP_.. \n" 110 | " D1_OMP_MTJP D1_OMP_MTJP_LF D1_OMP_MTJP_.. \n" 111 | "\n" 112 | " D1_OMP_HBJP_GM3P D1_OMP_HBJP_GM3P_.. D1_OMP_HBJP_GMMP.. D1_OMP_HBJP_.... \n" 113 | " D1_OMP_HBMTP_GM3P D1_OMP_HBMTJP_GM3P_.. D1_OMP_HBMTJP_GMMP.. D1_OMP_HBMTJP_....\n" 114 | "\n" 115 | " D2_OMP_GM3P D2_OMP_GM3P_LF D2_OMP_GM3P_.. \n" 116 | " D2_OMP_GMMP D2_OMP_GMMP_LF D2_OMP_GMMP_.. \n" 117 | " D2_OMP_SERIAL D2_OMP_SERIAL_LF D2_OMP_SERIAL_..\n" 118 | "\n" 119 | "Example:\n" 120 | " $./ColPack -f mc10.mtx mc15.mtx -o RANDOM -m D1_OMP_GM3P D2_OMP_GMMP_LF -v --nT 1 2 4 8\n" 121 | " $./ColPack -f bcsstk01.mtx -o RANDOM -m D1_OMP_HBJP_SERIAL -v -nT 10 -sit 4\n" 122 | " $./ColPack -f bcsstk01.mtx mc10.mtx -o RANDOM -m D2_OMP_GMMP D2_OMP_GMMP_LF -v -nT 10\n" 123 | "\n\n\n" 124 | ); 125 | } 126 | 127 | 128 | -------------------------------------------------------------------------------- /Examples/SampleDrivers/.gitignore: -------------------------------------------------------------------------------- 1 | /Basic/Generate_seed_matrix_for_Hessian 2 | /Basic/Generate_seed_matrix_for_Jacobian 3 | /Basic/color_bipartite_graph_using_BipartiteGraphBicoloringInterface 4 | /Basic/color_bipartite_graph_using_BipartiteGraphPartialColoringInterface 5 | /Basic/color_graph_using_GraphColoringInterface 6 | /Matrix_Compression_and_Recovery/ADIC/01_Column_compression_and_recovery_for_Jacobian_return_ADIC_Format 7 | /Matrix_Compression_and_Recovery/ADOL-C/01_Column_compression_and_recovery_for_Jacobian_return_Row_Compressed_Format 8 | /Matrix_Compression_and_Recovery/ADOL-C/02_Column_compression_and_recovery_for_Jacobian_return_Coordinate_Format 9 | /Matrix_Compression_and_Recovery/ADOL-C/03_Column_compression_and_recovery_for_Jacobian_return_Sparse_Solvers_Format 10 | /Matrix_Compression_and_Recovery/ADOL-C/04_Row_compression_and_recovery_for_Jacobian_return_Row_Compressed_Format 11 | /Matrix_Compression_and_Recovery/ADOL-C/05_Compression_and_direct_recovery_for_Hessian_return_Row_Compressed_Format 12 | /Matrix_Compression_and_Recovery/ADOL-C/06_Compression_and_direct_recovery_for_Hessian_return_Coordinate_Format 13 | /Matrix_Compression_and_Recovery/ADOL-C/07_Compression_and_direct_recovery_for_Hessian_return_Sparse_Solvers_Format 14 | /Matrix_Compression_and_Recovery/ADOL-C/08_Compression_and_indirect_recovery_for_Hessian_return_Row_Compressed_Format 15 | /Matrix_Compression_and_Recovery/ADOL-C/09_Bidirectional_compression_and_recovery_for_Jacobian_return_Row_Compressed_Format 16 | /Matrix_Compression_and_Recovery/ADOL-C/10_Column_compression_and_recovery_for_Jacobian_return_Row_Compressed_Format__unmanaged_usermem 17 | /Matrix_Compression_and_Recovery/ADOL-C/11_Compression_and_direct_recovery_for_Hessian_return_Row_Compressed_Format__unmanaged_usermem 18 | /Matrix_Compression_and_Recovery/ADOL-C/12_Bidirectional_compression_and_recovery_for_Jacobian_return_Row_Compressed_Format__unmanaged_usermem 19 | /Matrix_Compression_and_Recovery/CSR_input/01_Column_compression_and_recovery_for_Jacobian_CSR_input_return_Row_Compressed_Format 20 | /Matrix_Compression_and_Recovery/SMB/sparse_jac_hess 21 | -------------------------------------------------------------------------------- /Examples/SampleDrivers/Basic/Generate_seed_matrix_for_Hessian.cpp: -------------------------------------------------------------------------------- 1 | // An example for using GraphColoringInterface to generate the seed matrix for Hessian 2 | /* How to compile this driver manually: 3 | To compile the code, replace the Main.cpp file in Main directory with this file 4 | and run "make" in ColPack installation directory. Make will generate "ColPack.exe" executable 5 | Run "ColPack.exe" 6 | //*/ 7 | 8 | #include "ColPackHeaders.h" 9 | 10 | using namespace ColPack; 11 | using namespace std; 12 | 13 | int main() 14 | { 15 | double*** dp3_Seed = new double**; 16 | int *ip1_SeedRowCount = new int; 17 | int *ip1_SeedColumnCount = new int; 18 | int i_RowCount, i_MaxNonZerosInRows; 19 | 20 | //populate the Hessian. Uncomment one of the 2 matrices below 21 | 22 | /* 1x1 matrix 23 | i_RowCount = 1; 24 | i_MaxNonZerosInRows = 1; 25 | unsigned int **uip2_HessianSparsityPattern = new unsigned int *[i_RowCount];//[1][1] 26 | for(int i=0;i<1;i++) uip2_HessianSparsityPattern[i] = new unsigned int[i_MaxNonZerosInRows + 1]; 27 | uip2_HessianSparsityPattern[0][0] = 1; uip2_HessianSparsityPattern[0][1] = 0; 28 | //*/ 29 | 30 | //* 5x5 matrix 31 | i_RowCount = 5; 32 | i_MaxNonZerosInRows = 2; 33 | unsigned int **uip2_HessianSparsityPattern = new unsigned int *[i_RowCount];//[5][5] 34 | for(int i=0;i<5;i++) uip2_HessianSparsityPattern[i] = new unsigned int[i_MaxNonZerosInRows + 1]; 35 | uip2_HessianSparsityPattern[0][0] = 1; uip2_HessianSparsityPattern[0][1] = 1; 36 | uip2_HessianSparsityPattern[1][0] = 2; uip2_HessianSparsityPattern[1][1] = 0; uip2_HessianSparsityPattern[1][2] = 2; 37 | uip2_HessianSparsityPattern[2][0] = 2; uip2_HessianSparsityPattern[2][1] = 1; uip2_HessianSparsityPattern[2][2] = 3; 38 | uip2_HessianSparsityPattern[3][0] = 2; uip2_HessianSparsityPattern[3][1] = 2; uip2_HessianSparsityPattern[3][2] = 4; 39 | uip2_HessianSparsityPattern[4][0] = 1; uip2_HessianSparsityPattern[4][1] = 3; 40 | //*/ 41 | 42 | 43 | //Step 1: Read the sparsity pattern of the given Hessian matrix (compressed sparse rows format) 44 | //and create the corresponding graph 45 | GraphColoringInterface * g = new GraphColoringInterface(SRC_MEM_ADOLC, uip2_HessianSparsityPattern, i_RowCount); 46 | 47 | //Step 2: Color the bipartite graph with the specified ordering 48 | g->Coloring("SMALLEST_LAST", "STAR"); 49 | 50 | //Step 3: From the coloring information, create and return the seed matrix 51 | (*dp3_Seed) = g->GetSeedMatrix(ip1_SeedRowCount, ip1_SeedColumnCount); 52 | /* Notes: 53 | In stead of doing step 1-3, you can just call the bellow function: 54 | g->GenerateSeedHessian(uip2_HessianSparsityPattern, i_RowCount, dp3_Seed, ip1_SeedRowCount, ip1_SeedColumnCount, "STAR", "SMALLEST_LAST"); // this function is inside GraphColoringInterface class 55 | */ 56 | cout<<"Finish GenerateSeed()"<PrintGraphStructure(); 60 | g->PrintVertexColors(); 61 | g->PrintVertexColoringMetrics(); 62 | double **Seed = *dp3_Seed; 63 | int rows = g->GetVertexCount(); 64 | int cols = g->GetVertexColorCount(); 65 | cout<<"Seed matrix: ("< 36 | string s_InputFile; //path of the input file 37 | s_InputFile = baseDir; 38 | s_InputFile += DIR_SEPARATOR; s_InputFile += "Graphs"; s_InputFile += DIR_SEPARATOR; s_InputFile += "column-compress.mtx"; 39 | 40 | //Generate and color the bipartite graph 41 | BipartiteGraphBicoloringInterface *g = new BipartiteGraphBicoloringInterface(SRC_FILE, s_InputFile.c_str(), "AUTO_DETECTED"); 42 | 43 | //Color the graph based on the specified ordering and (Star) Bicoloring 44 | g->Bicoloring( "SMALLEST_LAST", "IMPLICIT_COVERING__STAR_BICOLORING"); 45 | 46 | /*Done with coloring. Below are possible things that you may 47 | want to do after coloring: 48 | //*/ 49 | 50 | //* 1. Check Star Bicoloring Coloring result 51 | cout<<"Check Star Bicoloring Coloring result ... "<CheckStarBicoloring(); 53 | //*/ 54 | 55 | //* 2. Print coloring results 56 | g->PrintVertexBicoloringMetrics(); 57 | //*/ 58 | 59 | //* 3. Get the list of colorID of colored vertices (in this case, the left side of the bipartite graph) 60 | vector vi_LeftVertexColors; 61 | g->GetLeftVertexColors(vi_LeftVertexColors); 62 | 63 | vector vi_RightVertexColors; 64 | g->GetRightVertexColors(vi_RightVertexColors); 65 | 66 | //Print Partial Colors 67 | g->PrintVertexBicolors(); 68 | //*/ 69 | 70 | //* 4. Get seed matrix 71 | int i_LeftSeedRowCount = 0; 72 | int i_LeftSeedColumnCount = 0; 73 | double** LeftSeed = g->GetLeftSeedMatrix(&i_LeftSeedRowCount, &i_LeftSeedColumnCount); 74 | 75 | int i_RightSeedRowCount = 0; 76 | int i_RightSeedColumnCount = 0; 77 | double** RightSeed = g->GetRightSeedMatrix(&i_RightSeedRowCount, &i_RightSeedColumnCount); 78 | 79 | //Display Seeds 80 | if(i_LeftSeedRowCount>0 && i_LeftSeedColumnCount > 0){ 81 | printf("Left Seed matrix %d x %d \n", i_LeftSeedRowCount, i_LeftSeedColumnCount); 82 | displayMatrix(LeftSeed, i_LeftSeedRowCount, i_LeftSeedColumnCount, 1); 83 | } 84 | 85 | if(i_RightSeedRowCount>0 && i_RightSeedColumnCount > 0) { 86 | printf("Right Seed matrix %d x %d \n", i_RightSeedRowCount, i_RightSeedColumnCount); 87 | displayMatrix(RightSeed, i_RightSeedRowCount, i_RightSeedColumnCount, 1); 88 | } 89 | //*/ 90 | 91 | delete g; 92 | return 0; 93 | } 94 | //*/ 95 | -------------------------------------------------------------------------------- /Examples/SampleDrivers/Basic/color_bipartite_graph_using_BipartiteGraphPartialColoringInterface.cpp: -------------------------------------------------------------------------------- 1 | // An example for using BipartiteGraphPartialColoringInterface to color Bipartite Graph 2 | /* 3 | How to compile this driver manually: 4 | Please make sure that "baseDir" point to the directory (folder) containing the input matrix file, and 5 | s_InputFile should point to the input file that you want to use 6 | To compile the code, replace the Main.cpp file in Main directory with this file 7 | and run "make" in ColPack installation directory. Make will generate "ColPack.exe" executable 8 | Run "ColPack.exe" 9 | 10 | Note: If you got "symbol lookup error ... undefined symbol " 11 | Please make sure that your LD_LIBRARY_PATH contains libColPack.so 12 | 13 | Any time you have trouble understanding what a routine does, how to use a routine, or what are the accepted values for a parameter, 14 | please reference the COLPACK's online documentation (temporarily located at 15 | http://www.cscapes.org/dox/ColPack/html/ ). 16 | 17 | For more information, please visit our webpage http://www.cscapes.org/coloringpage/ 18 | //*/ 19 | 20 | #include "ColPackHeaders.h" 21 | 22 | using namespace ColPack; 23 | using namespace std; 24 | 25 | #ifndef TOP_DIR 26 | #define TOP_DIR "." 27 | #endif 28 | 29 | // baseDir should point to the directory (folder) containing the input file 30 | string baseDir=TOP_DIR; 31 | 32 | //* A SHORT VERSION 33 | int main(int argc, char ** argv) 34 | { 35 | // s_InputFile = baseDir + 36 | string s_InputFile; //path of the input file 37 | s_InputFile = baseDir; 38 | s_InputFile += DIR_SEPARATOR; s_InputFile += "Graphs"; s_InputFile += DIR_SEPARATOR; s_InputFile += "column-compress.mtx"; 39 | 40 | //Generate and color the bipartite graph 41 | BipartiteGraphPartialColoringInterface *g = new BipartiteGraphPartialColoringInterface(SRC_FILE, s_InputFile.c_str(), "AUTO_DETECTED"); 42 | 43 | //Do Partial-Distance-Two-Coloring the bipartite graph with the specified ordering 44 | g->PartialDistanceTwoColoring("SMALLEST_LAST", "ROW_PARTIAL_DISTANCE_TWO"); 45 | 46 | /*Done with coloring. Below are possible things that you may 47 | want to do after coloring: 48 | //*/ 49 | 50 | /* 1. Check Partial Distance Two Coloring result 51 | cout<<"Check Partial Distance Two coloring result ... "<CheckPartialDistanceTwoColoring() == _FALSE) cout<<" FAILED"<PrintPartialColoringMetrics(); 58 | //*/ 59 | 60 | //* 3. Get the list of colorID of colored vertices (in this case, the left side of the bipartite graph) 61 | vector vi_VertexPartialColors; 62 | g->GetVertexPartialColors(vi_VertexPartialColors); 63 | 64 | //Print Partial Colors 65 | g->PrintPartialColors(); 66 | //*/ 67 | 68 | /* 4. Get seed matrix 69 | int i_SeedRowCount = 0; 70 | int i_SeedColumnCount = 0; 71 | double** Seed = g->GetSeedMatrix(&i_SeedRowCount, &i_SeedColumnCount); 72 | 73 | //Display Seed 74 | printf("Seed matrix %d x %d \n", i_SeedRowCount, i_SeedColumnCount); 75 | displayMatrix(Seed, i_SeedRowCount, i_SeedColumnCount, 1); 76 | //*/ 77 | 78 | delete g; 79 | return 0; 80 | } 81 | //*/ 82 | -------------------------------------------------------------------------------- /Examples/SampleDrivers/Basic/color_graph_using_GraphColoringInterface.cpp: -------------------------------------------------------------------------------- 1 | // An example for using GraphColoringInterface to color Graph 2 | /* 3 | How to compile this driver manually: 4 | Please make sure that "baseDir" point to the directory (folder) containing the input matrix file, and 5 | s_InputFile should point to the input file that you want to use 6 | To compile the code, replace the Main.cpp file in Main directory with this file 7 | and run "make" in ColPack installation directory. Make will generate "ColPack.exe" executable 8 | Run "ColPack.exe" 9 | 10 | Note: If you got "symbol lookup error ... undefined symbol " 11 | Please make sure that your LD_LIBRARY_PATH contains libColPack.so 12 | 13 | Any time you have trouble understanding what a routine does, how to use a routine, or what are the accepted values for a parameter, 14 | please reference the COLPACK's online documentation (temporarily located at 15 | http://www.cscapes.org/dox/ColPack/html/ ). 16 | 17 | For more information, please visit our webpage http://www.cscapes.org/coloringpage/ 18 | //*/ 19 | 20 | #include "ColPackHeaders.h" 21 | 22 | using namespace ColPack; 23 | using namespace std; 24 | 25 | #ifndef TOP_DIR 26 | #define TOP_DIR "." 27 | #endif 28 | 29 | // baseDir should point to the directory (folder) containing the input file 30 | string baseDir=TOP_DIR; 31 | 32 | //* A SHORT VERSION 33 | int main(int argc, char ** argv) 34 | { 35 | // s_InputFile = baseDir + 36 | string s_InputFile; //path of the input file. PICK A SYMMETRIC MATRIX!!! 37 | s_InputFile = baseDir; 38 | s_InputFile += DIR_SEPARATOR; s_InputFile += "Graphs"; s_InputFile += DIR_SEPARATOR; s_InputFile += "mtx-spear-head.mtx"; 39 | 40 | //Generate and color the graph 41 | GraphColoringInterface * g = new GraphColoringInterface(SRC_FILE, s_InputFile.c_str(), "AUTO_DETECTED"); 42 | 43 | //Color the bipartite graph with the specified ordering 44 | g->Coloring("LARGEST_FIRST", "DISTANCE_TWO"); 45 | 46 | /*Done with coloring. Below are possible things that you may 47 | want to do after coloring: 48 | //*/ 49 | 50 | /* 1. Check DISTANCE_TWO coloring result 51 | cout<<"Check DISTANCE_TWO coloring result"<CheckDistanceTwoColoring(); 53 | //*/ 54 | 55 | //* 2. Print coloring results 56 | g->PrintVertexColoringMetrics(); 57 | //*/ 58 | 59 | //* 3. Get the list of colorID of vertices 60 | vector vi_VertexColors; 61 | g->GetVertexColors(vi_VertexColors); 62 | 63 | //Display vector of VertexColors 64 | printf("vector of VertexColors (size %d) \n", (int)vi_VertexColors.size()); 65 | displayVector(&vi_VertexColors[0], vi_VertexColors.size(), 1); 66 | //*/ 67 | 68 | /* 4. Get seed matrix 69 | int i_SeedRowCount = 0; 70 | int i_SeedColumnCount = 0; 71 | double** Seed = g->GetSeedMatrix(&i_SeedRowCount, &i_SeedColumnCount); 72 | 73 | //Display Seed 74 | printf("Seed matrix %d x %d \n", i_SeedRowCount, i_SeedColumnCount); 75 | displayMatrix(Seed, i_SeedRowCount, i_SeedColumnCount, 1); 76 | //*/ 77 | 78 | delete g; 79 | return 0; 80 | } 81 | //*/ 82 | 83 | /* A LONGER VERSION showing steps actually executed by the constructor. 84 | int main(int argc, char ** argv) 85 | { 86 | // s_InputFile = baseDir + 87 | string s_InputFile; //path of the input file. PICK A SYMMETRIC MATRIX!!! 88 | s_InputFile = baseDir + "bcsstk01_symmetric\\bcsstk01_symmetric.mtx"; 89 | GraphColoringInterface * g = new GraphColoringInterface(); 90 | 91 | //Read a matrix from an input file and generate a corresponding graph. 92 | //The input format will be determined based on the file extension and a correct reading routine will be used to read the file. 93 | //Note: the input matrix MUST be SYMMETRIC in order for a graph to be generated correctly 94 | // If you are new to COLPACK, pick either a .graph file (MeTiS format) or a symmetric .mtx (Matrix Market format) 95 | if ( g->ReadAdjacencyGraph(s_InputFile) == _FALSE) { 96 | cout<<"ReadAdjacencyGraph() Failed!!!"<Coloring("DISTANCE_TWO", "LARGEST_FIRST"); 103 | cout<<"Done with Coloring()"<PrintVertexColoringMetrics(); 107 | cout<<"Done with PrintVertexColoringMetrics()"< 33 | string s_InputFile; //path of the input file 34 | s_InputFile = baseDir; 35 | s_InputFile += DIR_SEPARATOR; s_InputFile += "Graphs"; s_InputFile += DIR_SEPARATOR; s_InputFile += "column-compress.mtx"; 36 | //s_InputFile += DIR_SEPARATOR; s_InputFile += "Graphs"; s_InputFile += DIR_SEPARATOR; s_InputFile += "hess_pat.mtx"; 37 | 38 | // Step 1: Determine sparsity structure of the Jacobian. 39 | // This step is done by an AD tool. For the purpose of illustration here, we read the structure from a file, 40 | // and store the structure in a Compressed Row Format and then ADIC format. 41 | unsigned int *** uip3_SparsityPattern = new unsigned int **; //uip3_ means triple pointers of type unsigned int 42 | double*** dp3_Value = new double**; //dp3_ means triple pointers of type double. Other prefixes follow the same notation 43 | int rowCount, columnCount; 44 | ConvertMatrixMarketFormat2RowCompressedFormat(s_InputFile, uip3_SparsityPattern, dp3_Value,rowCount, columnCount); 45 | 46 | cout<<"just for debugging purpose, display the 2 matrices: the matrix with SparsityPattern only and the matrix with Value"< > lsi_SparsityPattern; 57 | std::list > lvd_Value; 58 | ConvertRowCompressedFormat2ADIC( (*uip3_SparsityPattern) , rowCount, (*dp3_Value), lsi_SparsityPattern, lvd_Value); 59 | 60 | cout<<"just for debugging purpose, display the matrix in ADIC format rowCount = "<PartialDistanceTwoColoring("SMALLEST_LAST", "COLUMN_PARTIAL_DISTANCE_TWO"); 77 | 78 | //Step 2.3: From the coloring information, you can get the vector of colorIDs of left or right vertices (depend on the s_ColoringVariant that you choose) 79 | vector vi_VertexPartialColors; 80 | g->GetVertexPartialColors(vi_VertexPartialColors); 81 | *ip1_ColorCount = g->GetRightVertexColorCount(); 82 | cout<<"Finish GetVertexPartialColors()"< > lvd_NewValue; 104 | JacobianRecovery1D* jr1d = new JacobianRecovery1D; 105 | jr1d->RecoverD2Cln_ADICFormat(g, *dp3_CompressedMatrix, lsi_SparsityPattern, lvd_NewValue); 106 | cout<<"Finish Recover()"< 34 | string s_InputFile; //path of the input file 35 | s_InputFile = baseDir; 36 | s_InputFile += DIR_SEPARATOR; s_InputFile += "Graphs"; s_InputFile += DIR_SEPARATOR; s_InputFile += "column-compress.mtx"; 37 | 38 | // Step 1: Determine sparsity structure of the Jacobian. 39 | // This step is done by an AD tool. For the purpose of illustration here, we read the structure from a file, 40 | // and store the structure in a Compressed Row Format. 41 | unsigned int *** uip3_SparsityPattern = new unsigned int **; //uip3_ means triple pointers of type unsigned int 42 | double*** dp3_Value = new double**; //dp3_ means triple pointers of type double. Other prefixes follow the same notation 43 | int rowCount, columnCount; 44 | ConvertMatrixMarketFormat2RowCompressedFormat(s_InputFile, uip3_SparsityPattern, dp3_Value,rowCount, columnCount); 45 | 46 | cout<<"just for debugging purpose, display the 2 matrices: the matrix with SparsityPattern only and the matrix with Value"<PartialDistanceTwoColoring("SMALLEST_LAST", "COLUMN_PARTIAL_DISTANCE_TWO"); 67 | 68 | //Step 2.3 (Option 1): From the coloring information, create and return the seed matrix 69 | (*dp3_Seed) = g->GetSeedMatrix(ip1_SeedRowCount, ip1_SeedColumnCount); 70 | /* Notes: 71 | Step 2.3 (Option 2): From the coloring information, you can also get the vector of colorIDs of left or right vertices (depend on the s_ColoringVariant that you choose) 72 | vector vi_VertexPartialColors; 73 | g->GetVertexPartialColors(vi_VertexPartialColors); 74 | */ 75 | cout<<"Finish GenerateSeed()"<RecoverD2Cln_RowCompressedFormat(g, *dp3_CompressedMatrix, *uip3_SparsityPattern, dp3_NewValue); 99 | cout<<"Finish Recover()"< 34 | string s_InputFile; //path of the input file 35 | s_InputFile = baseDir; 36 | s_InputFile += DIR_SEPARATOR; s_InputFile += "Graphs"; s_InputFile += DIR_SEPARATOR; s_InputFile += "row-compress.mtx"; 37 | 38 | // Step 1: Determine sparsity structure of the Jacobian. 39 | // This step is done by an AD tool. For the purpose of illustration here, we read the structure from a file, 40 | // and store the structure in a Compressed Row Format. 41 | unsigned int *** uip3_SparsityPattern = new unsigned int **; 42 | double*** dp3_Value = new double**; 43 | int rowCount, columnCount; 44 | ConvertMatrixMarketFormat2RowCompressedFormat(s_InputFile, uip3_SparsityPattern, dp3_Value,rowCount, columnCount); 45 | 46 | cout<<"just for debugging purpose, display the 2 matrices: the matrix with SparsityPattern only and the matrix with Value"<PartialDistanceTwoColoring("SMALLEST_LAST", "ROW_PARTIAL_DISTANCE_TWO"); 67 | 68 | //Step 2.3 (Option 1): From the coloring information, create and return the seed matrix 69 | (*dp3_Seed) = g->GetSeedMatrix(ip1_SeedRowCount, ip1_SeedColumnCount); 70 | /* Notes: 71 | Step 2.3 (Option 2): From the coloring information, you can also get the vector of colorIDs of left or right vertices (depend on the s_ColoringVariant that you choose) 72 | vector vi_VertexPartialColors; 73 | g->GetVertexPartialColors(vi_VertexPartialColors); 74 | */ 75 | cout<<"Finish GenerateSeed()"<RecoverD2Row_RowCompressedFormat(g, *dp3_CompressedMatrix, *uip3_SparsityPattern, dp3_NewValue); 99 | cout<<"Finish Recover()"< 32 | string s_InputFile; //path of the input file 33 | s_InputFile = baseDir; 34 | s_InputFile += DIR_SEPARATOR; s_InputFile += "Graphs"; s_InputFile += DIR_SEPARATOR; s_InputFile += "mtx-spear-head.mtx"; 35 | 36 | // Step 1: Determine sparsity structure of the Jacobian. 37 | // This step is done by an AD tool. For the purpose of illustration here, we read the structure from a file, 38 | // and store the structure in a Compressed Row Format. 39 | unsigned int *** uip3_SparsityPattern = new unsigned int **; 40 | double*** dp3_Value = new double**; 41 | int rowCount, columnCount; 42 | ConvertMatrixMarketFormat2RowCompressedFormat(s_InputFile, uip3_SparsityPattern, dp3_Value,rowCount, columnCount); 43 | 44 | cout<<"just for debugging purpose, display the 2 matrices: the matrix with SparsityPattern only and the matrix with Value"<Coloring("SMALLEST_LAST", "STAR"); 65 | 66 | //Step 2.3 (Option 1): From the coloring information, create and return the seed matrix 67 | (*dp3_Seed) = g->GetSeedMatrix(ip1_SeedRowCount, ip1_SeedColumnCount); 68 | /* Notes: 69 | Step 2.3 (Option 2): From the coloring information, you can also get the vector of colorIDs of vertices 70 | vector vi_VertexColors; 71 | g->GetVertexColors(vi_VertexColors); 72 | */ 73 | cout<<"Finish GenerateSeed()"<DirectRecover_RowCompressedFormat(g, *dp3_CompressedMatrix, *uip3_SparsityPattern, dp3_NewValue); 95 | cout<<"Finish Recover()"< 37 | string s_InputFile; //path of the input file 38 | s_InputFile = baseDir; 39 | s_InputFile += DIR_SEPARATOR; s_InputFile += "Graphs"; s_InputFile += DIR_SEPARATOR; s_InputFile += "mtx-spear-head.mtx"; 40 | 41 | // Step 1: Determine sparsity structure of the Jacobian. 42 | // This step is done by an AD tool. For the purpose of illustration here, we read the structure from a file, 43 | // and store the structure in a Compressed Row Format. 44 | unsigned int *** uip3_SparsityPattern = new unsigned int **; 45 | double*** dp3_Value = new double**; 46 | int rowCount, columnCount; 47 | ConvertMatrixMarketFormat2RowCompressedFormat(s_InputFile, uip3_SparsityPattern, dp3_Value,rowCount, columnCount); 48 | 49 | cout<<"just for debugging purpose, display the 2 matrices: the matrix with SparsityPattern only and the matrix with Value"<Coloring("SMALLEST_LAST", "STAR"); 70 | 71 | //Step 2.3 (Option 1): From the coloring information, create and return the seed matrix 72 | (*dp3_Seed) = g->GetSeedMatrix(ip1_SeedRowCount, ip1_SeedColumnCount); 73 | /* Notes: 74 | Step 2.3 (Option 2): From the coloring information, you can also get the vector of colorIDs of vertices 75 | vector vi_VertexColors; 76 | g->GetVertexColors(vi_VertexColors); 77 | */ 78 | cout<<"Finish GenerateSeed()"<DirectRecover_CoordinateFormat(g, *dp3_CompressedMatrix, *uip3_SparsityPattern, ip2_RowIndex, ip2_ColumnIndex, dp2_HessianValue); 102 | cout<<"Finish Recover()"< 34 | string s_InputFile; //path of the input file 35 | s_InputFile = baseDir; 36 | s_InputFile += DIR_SEPARATOR; s_InputFile += "Graphs"; s_InputFile += DIR_SEPARATOR; s_InputFile += "mtx-spear-head.mtx"; 37 | 38 | // Step 1: Determine sparsity structure of the Jacobian. 39 | // This step is done by an AD tool. For the purpose of illustration here, we read the structure from a file, 40 | // and store the structure in a Compressed Row Format. 41 | unsigned int *** uip3_SparsityPattern = new unsigned int **; 42 | double*** dp3_Value = new double**; 43 | int rowCount, columnCount; 44 | ConvertMatrixMarketFormat2RowCompressedFormat(s_InputFile, uip3_SparsityPattern, dp3_Value,rowCount, columnCount); 45 | 46 | cout<<"just for debugging purpose, display the 2 matrices: the matrix with SparsityPattern only and the matrix with Value"<Coloring("SMALLEST_LAST", "ACYCLIC_FOR_INDIRECT_RECOVERY"); 67 | 68 | //Step 2.3 (Option 1): From the coloring information, create and return the seed matrix 69 | (*dp3_Seed) = g->GetSeedMatrix(ip1_SeedRowCount, ip1_SeedColumnCount); 70 | /* Notes: 71 | Step 2.3 (Option 2): From the coloring information, you can also get the vector of colorIDs of vertices 72 | vector vi_VertexColors; 73 | g->GetVertexColors(vi_VertexColors); 74 | */ 75 | cout<<"Finish GenerateSeed()"<IndirectRecover_RowCompressedFormat(g, *dp3_CompressedMatrix, *uip3_SparsityPattern, dp3_NewValue); 97 | cout<<"Finish Indirect Recover()"< colors_C; 82 | // colors_C: colors vector (using ColPack?) 83 | 84 | //string s_InputFile = "test_mat.mtx"; 85 | string s_InputFile = "jac_pat.mtx"; 86 | 87 | unsigned int *rb=NULL; /* dependent variables */ 88 | unsigned int *cb=NULL; /* independent variables */ 89 | 90 | unsigned int **JP=NULL; /* compressed block row storage */ 91 | //JP: Jacobian Pattern 92 | JP = (unsigned int **) malloc(m*sizeof(unsigned int*)); 93 | 94 | unsigned int **JP2=NULL; /* compressed block row storage */ 95 | //JP2: also Jacobian Pattern 96 | JP2 = (unsigned int **) malloc(m*sizeof(unsigned int*)); 97 | 98 | int ctrl[2]; 99 | ctrl[0] = 0; ctrl[1] = 0; 100 | //ctrl[2]: for jac_pat(tag_c, m, n, x, JP, ctrl); //control options 101 | 102 | double tg_C,ts_C; 103 | //tg_C: time to read the input file and generate Graph (using ColPack) 104 | //ts_C: time to color and generate the seed matrix using ColPack 105 | BipartiteGraphPartialColoringInterface * gGraph = new BipartiteGraphPartialColoringInterface(); 106 | 107 | 108 | -------------------------------------------------------------------------------- /Examples/SomeExample/Main.cpp: -------------------------------------------------------------------------------- 1 | #include "ColPackHeaders.h" 2 | #include 3 | #include 4 | using namespace ColPack; 5 | void usage(); 6 | 7 | int main(int argc, char* argv[]) { 8 | string fname; 9 | string order("LARGEST_FIRST"); 10 | string methd("DISTANCE_ONE"); 11 | bool bVerbose(false); 12 | unordered_set ParaD1Color={"DISTANCE_ONE_OMP"}; 13 | unordered_set BiColor={ 14 | "IMPLICIT_COVERING__STAR_BICOLORING", 15 | "EXPLICIT_COVERING__STAR_BICOLORING", 16 | "EXPLICIT_COVERING__MODIFIED_STAR_BICOLORING", 17 | "IMPLICIT_COVERING__GREEDY_STAR_BICOLORING" 18 | }; 19 | unordered_set PartialColor={ 20 | "COLUMN_PARTIAL_DISTANCE_TWO", 21 | "ROW_PARTIAL_DISTANCE_TWO" 22 | }; 23 | 24 | 25 | for(int i=1; iBicoloring(order.c_str(), methd.c_str()); 40 | if(bVerbose) fprintf(stdout, "number of colors: "); 41 | fprintf(stdout,"%d", p->GetVertexColorCount()); 42 | delete p; p=nullptr; 43 | } 44 | else if(PartialColor.count(methd)){ 45 | if(bVerbose) fprintf(stdout,"\ngraph: %s\norder: %s\nmethd: %s\nPartial Distantce Two Coloring\n",fname.c_str(), order.c_str(), methd.c_str()); 46 | BipartiteGraphPartialColoringInterface *p = new BipartiteGraphPartialColoringInterface(0, fname.c_str(), "AUTO_DETECTED"); 47 | p->PartialDistanceTwoColoring(order.c_str(), methd.c_str()); 48 | if(bVerbose) fprintf(stdout, "number of colors: "); 49 | fprintf(stdout,"%d", p->GetVertexColorCount()); 50 | delete p; p=nullptr; 51 | } 52 | else if(ParaD1Color.count(methd)){ 53 | if(bVerbose) fprintf(stdout,"\ngraph: %s\norder: %s\nmethd: %s\nShared Memory General Graph Coloring\n",fname.c_str(), order.c_str(), methd.c_str()); 54 | GraphColoringInterface *g = new GraphColoringInterface(SRC_FILE, fname.c_str(), "AUTO_DETECTED"); 55 | g->Coloring(order.c_str(), methd.c_str()); 56 | delete g; g=nullptr; 57 | } 58 | else{ 59 | if(bVerbose) fprintf(stdout,"\ngraph: %s\norder: %s\nmethd: %s\nGeneral Graph Coloring\n",fname.c_str(), order.c_str(), methd.c_str()); 60 | GraphColoringInterface *g = new GraphColoringInterface(SRC_FILE, fname.c_str(), "AUTO_DETECTED"); 61 | g->Coloring(order.c_str(), methd.c_str()); 62 | if(bVerbose) fprintf(stdout, "number of colors: "); 63 | fprintf(stdout,"%d",g->GetVertexColorCount()); 64 | delete g; g=nullptr; 65 | } 66 | if(bVerbose)fprintf(stdout,"\n\n"); 67 | return 0; 68 | } 69 | 70 | void usage(){ 71 | fprintf(stderr, "\nusage: ./ColPack -f -o -m [-v]\n" 72 | "-f : Input file name\n" 73 | "-o : LARGEST_FIRST\n" 74 | " SMALLEST_LAST,\n" 75 | " DYNAMIC_LARGEST_FIRST,\n" 76 | " INCIDENCE_DEGREE,\n" 77 | " NATURAL,\n" 78 | " RANDOM\n" 79 | "-m : DISTANCE_ONE\n" 80 | " ACYCLIC\n" 81 | " ACYCLIC_FOR_INDIRECT_RECOVERY\n" 82 | " STAR\n" 83 | " RESTRICTED_STAR\n" 84 | " DISTANCE_TWO\n" 85 | " --------------------\n" 86 | " DISTANCE_ONE_OMP (automatic display: nThreads,num_colors,timall,conflicts,loops)\n " 87 | " --------------------\n" 88 | " IMPLICIT_COVERING__STAR_BICOLORING\n" 89 | " EXPLICIT_COVERING__STAR_BICOLORING\n" 90 | " EXPLICIT_COVERING__MODIFIED_STAR_BICOLORING\n" 91 | " IMPLICIT_COVERING__GREEDY_STAR_BICOLORING\n" 92 | " --------------------\n" 93 | " COLUMN_PARTIAL_DISTANCE_TWO\n" 94 | " ROW_PARTIAL_DISTANCE_TWO\n" 95 | "\n" 96 | "-v : verbose for debug infomation\n" 97 | "\n" 98 | "\n" 99 | "Examples:\n" 100 | "./ColPack -f ../Graphs/bcsstk01.mtx -o LARGEST_FIRST -m DISTANCE_ONE -v\n" 101 | "./ColPack -f ../Graphs/bcsstk01.mtx -o SMALLEST_LAST -m ACYCLIC -v\n" 102 | "./ColPack -f ../Graphs/bcsstk01.mtx -o DYNAMIC_LARGEST_FIRST -m DISTANCE_ONE_OMP -v\n" 103 | "\n" 104 | ); 105 | } 106 | 107 | 108 | -------------------------------------------------------------------------------- /Examples/Use_Library/Makefile: -------------------------------------------------------------------------------- 1 | # make file for using installed library 2 | # author xin cheng 3 | # usage: chage the following two variable accordingly 4 | COLPACK_INSTALL_PATH = ../../libs/libColPack.so 5 | COLPACK_ROOT = ../.. 6 | 7 | SRC = $(wildcard *.cpp) 8 | OBJ = $(SRC:%.cpp=%.o) 9 | EXE = ColPack 10 | 11 | # compiler 12 | COMPILE = g++ # gnu 13 | 14 | # compile flags 15 | CCFLAGS = -Wall -fopenmp -O3 -std=c++11 16 | 17 | # link flags 18 | LDFLAGS = -Wall -fopenmp -O3 -std=c++11 -ldl ${COLPACK_INSTALL_PATH} 19 | 20 | INCLUDES = -I./ 21 | INCLUDES+= -I${COLPACK_ROOT}/INC 22 | INCLUDES+= -I${COLPACK_ROOT}/SRC/GeneralGraphColoring 23 | INCLUDES+= -I${COLPACK_ROOT}/SRC/BipartiteGraphBicoloring 24 | INCLUDES+= -I${COLPACK_ROOT}/SRC/BipartiteGraphPartialColoring 25 | INCLUDES+= -I${COLPACK_ROOT}/SRC/Utilities 26 | 27 | 28 | all: $(EXE) 29 | 30 | %.o : %.cpp 31 | $(COMPILE) $(INCLUDES) $(CCFLAGS) -c $< -o $@ 32 | 33 | $(EXE): $(OBJ) 34 | $(COMPILE) $^ $(INCLUDES) $(LDFLAGS) -o $@ 35 | 36 | clean: 37 | rm -f $(OBJ) $(EXE) 38 | 39 | -------------------------------------------------------------------------------- /Examples/Use_Library/README.md: -------------------------------------------------------------------------------- 1 | this folder contains templated code for example of using ColPack as an Library. 2 | 3 | Firstly, make suer ColPack have been installed as an Library in your computer. 4 | 5 | Then, check and modify Makefile as needed. 6 | 7 | in your code (i.e. templated.cpp) include ColPack header and use ColPack. 8 | 9 | In then end, save your edit, make and run. 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Examples/Use_Library/template.cpp: -------------------------------------------------------------------------------- 1 | #include "ColPackHeaders.h" 2 | #include 3 | #include 4 | using namespace ColPack; 5 | void usage(); 6 | 7 | int main(int argc, char* argv[]) { 8 | string fname; 9 | string order("LARGEST_FIRST"); 10 | string methd("DISTANCE_ONE"); 11 | bool bVerbose(false); 12 | unordered_set ParaD1Color={"DISTANCE_ONE_OMP"}; 13 | unordered_set BiColor={ 14 | "IMPLICIT_COVERING__STAR_BICOLORING", 15 | "EXPLICIT_COVERING__STAR_BICOLORING", 16 | "EXPLICIT_COVERING__MODIFIED_STAR_BICOLORING", 17 | "IMPLICIT_COVERING__GREEDY_STAR_BICOLORING" 18 | }; 19 | unordered_set PartialColor={ 20 | "COLUMN_PARTIAL_DISTANCE_TWO", 21 | "ROW_PARTIAL_DISTANCE_TWO" 22 | }; 23 | 24 | 25 | for(int i=1; iBicoloring(order.c_str(), methd.c_str()); 40 | if(bVerbose) fprintf(stdout, "number of colors: "); 41 | fprintf(stdout,"%d\n", p->GetVertexColorCount()); 42 | delete p; p=nullptr; 43 | } 44 | else if(PartialColor.count(methd)){ 45 | if(bVerbose) fprintf(stdout,"\ngraph: %s\norder: %s\nmethd: %s\nPartial Distantce Two Coloring\n",fname.c_str(), order.c_str(), methd.c_str()); 46 | BipartiteGraphPartialColoringInterface *p = new BipartiteGraphPartialColoringInterface(0, fname.c_str(), "AUTO_DETECTED"); 47 | p->PartialDistanceTwoColoring(order.c_str(), methd.c_str()); 48 | if(bVerbose) fprintf(stdout, "number of colors: "); 49 | fprintf(stdout,"%d\n", p->GetVertexColorCount()); 50 | delete p; p=nullptr; 51 | } 52 | else if(ParaD1Color.count(methd)){ 53 | if(bVerbose) fprintf(stdout,"\ngraph: %s\norder: %s\nmethd: %s\nShared Memory General Graph Coloring\n",fname.c_str(), order.c_str(), methd.c_str()); 54 | GraphColoringInterface *g = new GraphColoringInterface(SRC_FILE, fname.c_str(), "AUTO_DETECTED"); 55 | g->Coloring(order.c_str(), methd.c_str()); 56 | delete g; g=nullptr; 57 | } 58 | else{ 59 | if(bVerbose) fprintf(stdout,"\ngraph: %s\norder: %s\nmethd: %s\nGeneral Graph Coloring\n",fname.c_str(), order.c_str(), methd.c_str()); 60 | GraphColoringInterface *g = new GraphColoringInterface(SRC_FILE, fname.c_str(), "AUTO_DETECTED"); 61 | g->Coloring(order.c_str(), methd.c_str()); 62 | if(bVerbose) fprintf(stdout, "number of colors: "); 63 | fprintf(stdout,"%d\n",g->GetVertexColorCount()); 64 | delete g; g=nullptr; 65 | } 66 | if(bVerbose) fprintf(stdout,"\n"); 67 | return 0; 68 | } 69 | 70 | void usage(){ 71 | fprintf(stderr, "\nusage: ./ColPack -f -o -m [-v]\n" 72 | "-f : Input file name\n" 73 | "-o : LARGEST_FIRST\n" 74 | " SMALLEST_LAST,\n" 75 | " DYNAMIC_LARGEST_FIRST,\n" 76 | " INCIDENCE_DEGREE,\n" 77 | " NATURAL,\n" 78 | " RANDOM\n" 79 | "-m : DISTANCE_ONE\n" 80 | " ACYCLIC\n" 81 | " ACYCLIC_FOR_INDIRECT_RECOVERY\n" 82 | " STAR\n" 83 | " RESTRICTED_STAR\n" 84 | " DISTANCE_TWO\n" 85 | " --------------------\n" 86 | " DISTANCE_ONE_OMP (automatic display: nThreads,num_colors,timall,conflicts,loops)\n " 87 | " --------------------\n" 88 | " IMPLICIT_COVERING__STAR_BICOLORING\n" 89 | " EXPLICIT_COVERING__STAR_BICOLORING\n" 90 | " EXPLICIT_COVERING__MODIFIED_STAR_BICOLORING\n" 91 | " IMPLICIT_COVERING__GREEDY_STAR_BICOLORING\n" 92 | " --------------------\n" 93 | " COLUMN_PARTIAL_DISTANCE_TWO\n" 94 | " ROW_PARTIAL_DISTANCE_TWO\n" 95 | "\n" 96 | "-v : verbose infomation\n" 97 | "\n" 98 | "\n" 99 | "Examples:\n" 100 | "./ColPack -f ../Graphs/bcsstk01.mtx -o LARGEST_FIRST -m DISTANCE_ONE -v\n" 101 | "./ColPack -f ../Graphs/bcsstk01.mtx -o SMALLEST_LAST -m ACYCLIC -v\n" 102 | "./ColPack -f ../Graphs/bcsstk01.mtx -o DYNAMIC_LARGEST_FIRST -m DISTANCE_ONE_OMP -v\n" 103 | "\n" 104 | ); 105 | } 106 | 107 | 108 | -------------------------------------------------------------------------------- /Graphs/bcsstk01.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CSCsw/ColPack/9a7293a8dfd66a60434496b8df5ebb4274d70339/Graphs/bcsstk01.gif -------------------------------------------------------------------------------- /Graphs/bcsstk01.rsa: -------------------------------------------------------------------------------- 1 | 1SYMMETRIC STIFFNESS MATRIX SMALL GENERALIZED EIGENVALUE PROBLEM BCSSTK01 2 | 74 4 14 56 0 3 | RSA 48 48 224 0 4 | (16I5) (16I5) (4E20.12) 5 | 1 9 17 25 31 37 43 49 55 62 66 70 75 85 95 104 6 | 112 120 127 132 136 141 144 146 149 154 158 161 164 167 169 173 7 | 178 183 185 188 191 196 201 205 208 211 213 216 219 221 222 224 8 | 225 9 | 1 5 6 7 11 19 25 30 2 4 6 8 10 20 24 26 10 | 3 4 5 9 21 23 27 28 4 8 10 22 27 28 5 7 11 | 11 21 23 29 6 12 20 24 25 30 7 11 12 13 31 36 12 | 8 10 12 14 18 32 9 10 11 15 17 33 34 10 16 33 13 | 34 11 15 17 35 12 14 18 31 36 13 17 18 19 23 37 14 | 42 43 47 48 14 15 16 18 20 22 38 44 45 46 15 16 15 | 17 21 39 40 44 45 46 16 20 22 39 40 44 45 46 17 16 | 18 19 23 41 43 47 48 18 24 37 42 43 47 48 19 23 17 | 24 43 48 20 22 24 44 21 22 23 45 46 22 45 46 23 18 | 47 24 43 48 25 29 30 31 35 26 28 32 34 27 28 33 19 | 28 32 34 29 31 35 30 36 31 35 36 37 32 34 36 38 20 | 42 33 34 35 39 41 34 40 35 39 41 36 38 42 37 41 21 | 42 43 47 38 40 42 44 46 39 40 41 45 40 44 46 41 22 | 43 47 42 48 43 47 48 44 45 46 45 46 46 47 48 48 23 | .283226851852E+07 .100000000000E+07 .208333333333E+07 -.333333333333E+04 24 | .100000000000E+07 -.280000000000E+07 -.289351851852E+05 .208333333333E+07 25 | .163544753086E+07 -.200000000000E+07 .555555555555E+07 -.666666666667E+04 26 | -.200000000000E+07 -.308641975309E+05 .555555555555E+07 -.159791666667E+07 27 | .172436728395E+07 -.208333333333E+07 -.277777777778E+07 -.168000000000E+07 28 | -.154320987654E+05 -.277777777778E+07 -.289351851852E+05 -.208333333333E+07 29 | .100333333333E+10 .200000000000E+07 .400000000000E+09 -.333333333333E+07 30 | .208333333333E+07 .100000000000E+09 .106750000000E+10 -.100000000000E+07 31 | .200000000000E+09 .277777777778E+07 .333333333333E+09 -.833333333333E+06 32 | .153533333333E+10 -.200000000000E+07 -.555555555555E+07 .666666666667E+09 33 | -.208333333333E+07 .100000000000E+09 .283226851852E+07 -.100000000000E+07 34 | .208333333333E+07 -.280000000000E+07 -.289351851852E+05 .208333333333E+07 35 | .163544753086E+07 .200000000000E+07 .555555555555E+07 -.308641975309E+05 36 | .555555555555E+07 -.159791666667E+07 .172436728395E+07 -.208333333333E+07 37 | -.277777777778E+07 -.154320987654E+05 -.277777777778E+07 -.289351851852E+05 38 | -.208333333333E+07 .100333333333E+10 -.333333333333E+07 .208333333333E+07 39 | .100000000000E+09 .106750000000E+10 .277777777778E+07 .333333333333E+09 40 | -.833333333333E+06 .153533333333E+10 -.555555555555E+07 .666666666667E+09 41 | -.208333333333E+07 .100000000000E+09 .283609946950E+07 -.214928529451E+07 42 | .235916180402E+07 -.333333333333E+04 -.100000000000E+07 -.289351851852E+05 43 | .208333333333E+07 -.383095098171E+04 -.114928529451E+07 .275828470683E+06 44 | .176741074446E+07 .517922131816E+06 .429857058902E+07 -.555555555555E+07 45 | -.666666666667E+04 .200000000000E+07 -.159791666667E+07 -.131963213599E+06 46 | -.517922131816E+06 .229857058902E+07 .389003806848E+07 -.263499027470E+07 47 | .277777777778E+07 -.168000000000E+07 -.289351851852E+05 -.208333333333E+07 48 | -.517922131816E+06 -.216567078453E+07 -.551656941367E+06 .197572063531E+10 49 | -.200000000000E+07 .400000000000E+09 .208333333333E+07 .100000000000E+09 50 | -.229857058902E+07 .551656941366E+06 .486193650990E+09 .152734651547E+10 51 | -.109779731332E+09 .100000000000E+07 .200000000000E+09 -.833333333333E+06 52 | .114928529451E+07 .229724661236E+09 -.557173510779E+08 .156411143711E+10 53 | -.200000000000E+07 -.208333333333E+07 .100000000000E+09 -.275828470683E+06 54 | -.557173510779E+08 .109411960038E+08 .283226851852E+07 .100000000000E+07 55 | .208333333333E+07 -.289351851852E+05 .208333333333E+07 .163544753086E+07 56 | -.200000000000E+07 -.555555555555E+07 -.159791666667E+07 .172436728395E+07 57 | -.208333333333E+07 .277777777778E+07 -.289351851852E+05 -.208333333333E+07 58 | .100333333333E+10 .208333333333E+07 .100000000000E+09 .106750000000E+10 59 | -.833333333333E+06 .153533333333E+10 -.208333333333E+07 .100000000000E+09 60 | .608796296296E+05 .125000000000E+07 .416666666667E+06 -.416666666667E+04 61 | .125000000000E+07 .337291666667E+07 -.250000000000E+07 -.833333333333E+04 62 | -.250000000000E+07 .241171296296E+07 -.416666666667E+06 -.235500000000E+07 63 | .150000000000E+10 .250000000000E+07 .500000000000E+09 .501833333333E+09 64 | -.125000000000E+07 .250000000000E+09 .502500000000E+09 -.250000000000E+07 65 | .398587962963E+07 -.125000000000E+07 .416666666667E+06 -.392500000000E+07 66 | .341149691358E+07 .250000000000E+07 .694444444444E+07 -.385802469136E+05 67 | .694444444445E+07 .243100308642E+07 -.416666666667E+06 -.347222222222E+07 68 | -.192901234568E+05 -.347222222222E+07 .150416666667E+10 -.416666666667E+07 69 | .133516666667E+10 .347222222222E+07 .416666666667E+09 .216916666667E+10 70 | -.694444444444E+07 .833333333333E+09 .398587962963E+07 -.125000000000E+07 71 | .416666666667E+06 -.416666666667E+04 -.125000000000E+07 .341149691358E+07 72 | .250000000000E+07 -.694444444445E+07 -.833333333333E+04 .250000000000E+07 73 | .243100308642E+07 -.416666666667E+06 .347222222222E+07 -.235500000000E+07 74 | .150416666667E+10 -.250000000000E+07 .500000000000E+09 .133516666667E+10 75 | .125000000000E+07 .250000000000E+09 .216916666667E+10 -.250000000000E+07 76 | .647105806113E+05 .239928529451E+07 .140838195984E+06 .350487988027E+07 77 | .517922131816E+06 -.479857058902E+07 .457738374749E+07 .134990274700E+06 78 | .247238730198E+10 .961679848804E+09 -.109779731332E+09 .531278103775E+09 79 | -------------------------------------------------------------------------------- /Graphs/bcsstm01.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CSCsw/ColPack/9a7293a8dfd66a60434496b8df5ebb4274d70339/Graphs/bcsstm01.gif -------------------------------------------------------------------------------- /Graphs/bcsstm01.mtx: -------------------------------------------------------------------------------- 1 | %%MatrixMarket matrix coordinate real symmetric 2 | 48 48 48 3 | 1 1 1.0000000000000e+02 4 | 2 2 1.0000000000000e+02 5 | 3 3 1.0000000000000e+02 6 | 4 4 0.0000000000000e+00 7 | 5 5 0.0000000000000e+00 8 | 6 6 0.0000000000000e+00 9 | 7 7 1.0000000000000e+02 10 | 8 8 1.0000000000000e+02 11 | 9 9 1.0000000000000e+02 12 | 10 10 0.0000000000000e+00 13 | 11 11 0.0000000000000e+00 14 | 12 12 0.0000000000000e+00 15 | 13 13 1.0000000000000e+02 16 | 14 14 1.0000000000000e+02 17 | 15 15 1.0000000000000e+02 18 | 16 16 0.0000000000000e+00 19 | 17 17 0.0000000000000e+00 20 | 18 18 0.0000000000000e+00 21 | 19 19 1.0000000000000e+02 22 | 20 20 1.0000000000000e+02 23 | 21 21 1.0000000000000e+02 24 | 22 22 0.0000000000000e+00 25 | 23 23 0.0000000000000e+00 26 | 24 24 0.0000000000000e+00 27 | 25 25 2.0000000000000e+02 28 | 26 26 2.0000000000000e+02 29 | 27 27 2.0000000000000e+02 30 | 28 28 0.0000000000000e+00 31 | 29 29 0.0000000000000e+00 32 | 30 30 0.0000000000000e+00 33 | 31 31 2.0000000000000e+02 34 | 32 32 2.0000000000000e+02 35 | 33 33 2.0000000000000e+02 36 | 34 34 0.0000000000000e+00 37 | 35 35 0.0000000000000e+00 38 | 36 36 0.0000000000000e+00 39 | 37 37 2.0000000000000e+02 40 | 38 38 2.0000000000000e+02 41 | 39 39 2.0000000000000e+02 42 | 40 40 0.0000000000000e+00 43 | 41 41 0.0000000000000e+00 44 | 42 42 0.0000000000000e+00 45 | 43 43 2.0000000000000e+02 46 | 44 44 2.0000000000000e+02 47 | 45 45 2.0000000000000e+02 48 | 46 46 0.0000000000000e+00 49 | 47 47 0.0000000000000e+00 50 | 48 48 0.0000000000000e+00 51 | -------------------------------------------------------------------------------- /Graphs/bcsstm01.rsa: -------------------------------------------------------------------------------- 1 | 1SYMMETRIC MASS MATRIX SMALL GENERALIZED EIGENVALUE PROBLEM, B MATRIX BCSSTM01 2 | 19 4 3 12 0 3 | RSA 48 48 48 0 4 | (16I5) (16I5) (4E20.12) 5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 6 | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 7 | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 8 | 49 9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 10 | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 11 | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 12 | .100000000000E+03 .100000000000E+03 .100000000000E+03 0. 13 | 0. 0. .100000000000E+03 .100000000000E+03 14 | .100000000000E+03 0. 0. 0. 15 | .100000000000E+03 .100000000000E+03 .100000000000E+03 0. 16 | 0. 0. .100000000000E+03 .100000000000E+03 17 | .100000000000E+03 0. 0. 0. 18 | .200000000000E+03 .200000000000E+03 .200000000000E+03 0. 19 | 0. 0. .200000000000E+03 .200000000000E+03 20 | .200000000000E+03 0. 0. 0. 21 | .200000000000E+03 .200000000000E+03 .200000000000E+03 0. 22 | 0. 0. .200000000000E+03 .200000000000E+03 23 | .200000000000E+03 0. 0. 0. 24 | -------------------------------------------------------------------------------- /Graphs/column-compress.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CSCsw/ColPack/9a7293a8dfd66a60434496b8df5ebb4274d70339/Graphs/column-compress.jpg -------------------------------------------------------------------------------- /Graphs/column-compress.mtx: -------------------------------------------------------------------------------- 1 | %%MatrixMarket matrix coordinate real general 2 | 10 10 19 3 | 1 1 .666666666666667 4 | 2 1 .27224066696528 5 | 2 2 .27224066696528 6 | 3 1 .27224066696528 7 | 3 3 .577703998805546 8 | 4 1 .27224066696528 9 | 4 4 .283314888590275 10 | 5 1 .27224066696528 11 | 5 5 .283314888590275 12 | 6 1 .27224066696528 13 | 6 6 .283314888590275 14 | 7 1 .27224066696528 15 | 7 7 .283314888590275 16 | 8 1 .27224066696528 17 | 8 8 .283314888590275 18 | 9 1 .27224066696528 19 | 9 9 .283314888590275 20 | 10 1 .27224066696528 21 | 10 10 .283314888590275 22 | -------------------------------------------------------------------------------- /Graphs/hess_pat.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CSCsw/ColPack/9a7293a8dfd66a60434496b8df5ebb4274d70339/Graphs/hess_pat.jpg -------------------------------------------------------------------------------- /Graphs/hess_pat.mtx: -------------------------------------------------------------------------------- 1 | %%MatrixMarket matrix coordinate real general 2 | 43 43 230 3 | 1 1 1.0 4 | 1 2 1.0 5 | 1 5 1.0 6 | 1 15 1.0 7 | 1 16 1.0 8 | 1 19 1.0 9 | 2 1 1.0 10 | 2 2 1.0 11 | 2 3 1.0 12 | 2 4 1.0 13 | 2 5 1.0 14 | 2 15 1.0 15 | 2 16 1.0 16 | 2 17 1.0 17 | 2 18 1.0 18 | 2 19 1.0 19 | 3 2 1.0 20 | 3 3 1.0 21 | 3 4 1.0 22 | 3 16 1.0 23 | 3 17 1.0 24 | 3 18 1.0 25 | 4 2 1.0 26 | 4 3 1.0 27 | 4 4 1.0 28 | 4 5 1.0 29 | 4 7 1.0 30 | 4 9 1.0 31 | 4 16 1.0 32 | 4 17 1.0 33 | 4 18 1.0 34 | 4 19 1.0 35 | 4 21 1.0 36 | 4 23 1.0 37 | 5 1 1.0 38 | 5 2 1.0 39 | 5 4 1.0 40 | 5 5 1.0 41 | 5 6 1.0 42 | 5 15 1.0 43 | 5 16 1.0 44 | 5 18 1.0 45 | 5 19 1.0 46 | 5 20 1.0 47 | 6 5 1.0 48 | 6 6 1.0 49 | 6 11 1.0 50 | 6 12 1.0 51 | 6 13 1.0 52 | 6 19 1.0 53 | 6 20 1.0 54 | 6 25 1.0 55 | 6 26 1.0 56 | 6 27 1.0 57 | 7 4 1.0 58 | 7 7 1.0 59 | 7 8 1.0 60 | 7 9 1.0 61 | 7 18 1.0 62 | 7 21 1.0 63 | 7 22 1.0 64 | 7 23 1.0 65 | 8 7 1.0 66 | 8 8 1.0 67 | 8 21 1.0 68 | 8 22 1.0 69 | 9 4 1.0 70 | 9 7 1.0 71 | 9 9 1.0 72 | 9 10 1.0 73 | 9 14 1.0 74 | 9 18 1.0 75 | 9 21 1.0 76 | 9 23 1.0 77 | 9 24 1.0 78 | 9 28 1.0 79 | 10 9 1.0 80 | 10 10 1.0 81 | 10 11 1.0 82 | 10 23 1.0 83 | 10 24 1.0 84 | 10 25 1.0 85 | 11 6 1.0 86 | 11 10 1.0 87 | 11 11 1.0 88 | 11 20 1.0 89 | 11 24 1.0 90 | 11 25 1.0 91 | 12 6 1.0 92 | 12 12 1.0 93 | 12 13 1.0 94 | 12 20 1.0 95 | 12 26 1.0 96 | 12 27 1.0 97 | 13 6 1.0 98 | 13 12 1.0 99 | 13 13 1.0 100 | 13 14 1.0 101 | 13 20 1.0 102 | 13 26 1.0 103 | 13 27 1.0 104 | 13 28 1.0 105 | 14 9 1.0 106 | 14 13 1.0 107 | 14 14 1.0 108 | 14 23 1.0 109 | 14 27 1.0 110 | 14 28 1.0 111 | 15 1 1.0 112 | 15 2 1.0 113 | 15 5 1.0 114 | 15 15 1.0 115 | 15 16 1.0 116 | 15 19 1.0 117 | 16 1 1.0 118 | 16 2 1.0 119 | 16 3 1.0 120 | 16 4 1.0 121 | 16 5 1.0 122 | 16 15 1.0 123 | 16 16 1.0 124 | 16 17 1.0 125 | 16 18 1.0 126 | 16 19 1.0 127 | 17 2 1.0 128 | 17 3 1.0 129 | 17 4 1.0 130 | 17 16 1.0 131 | 17 17 1.0 132 | 17 18 1.0 133 | 18 2 1.0 134 | 18 3 1.0 135 | 18 4 1.0 136 | 18 5 1.0 137 | 18 7 1.0 138 | 18 9 1.0 139 | 18 16 1.0 140 | 18 17 1.0 141 | 18 18 1.0 142 | 18 19 1.0 143 | 18 21 1.0 144 | 18 23 1.0 145 | 19 1 1.0 146 | 19 2 1.0 147 | 19 4 1.0 148 | 19 5 1.0 149 | 19 6 1.0 150 | 19 15 1.0 151 | 19 16 1.0 152 | 19 18 1.0 153 | 19 19 1.0 154 | 19 20 1.0 155 | 20 5 1.0 156 | 20 6 1.0 157 | 20 11 1.0 158 | 20 12 1.0 159 | 20 13 1.0 160 | 20 19 1.0 161 | 20 20 1.0 162 | 20 25 1.0 163 | 20 26 1.0 164 | 20 27 1.0 165 | 21 4 1.0 166 | 21 7 1.0 167 | 21 8 1.0 168 | 21 9 1.0 169 | 21 18 1.0 170 | 21 21 1.0 171 | 21 22 1.0 172 | 21 23 1.0 173 | 22 7 1.0 174 | 22 8 1.0 175 | 22 21 1.0 176 | 22 22 1.0 177 | 23 4 1.0 178 | 23 7 1.0 179 | 23 9 1.0 180 | 23 10 1.0 181 | 23 14 1.0 182 | 23 18 1.0 183 | 23 21 1.0 184 | 23 23 1.0 185 | 23 24 1.0 186 | 23 28 1.0 187 | 24 9 1.0 188 | 24 10 1.0 189 | 24 11 1.0 190 | 24 23 1.0 191 | 24 24 1.0 192 | 24 25 1.0 193 | 25 6 1.0 194 | 25 10 1.0 195 | 25 11 1.0 196 | 25 20 1.0 197 | 25 24 1.0 198 | 25 25 1.0 199 | 26 6 1.0 200 | 26 12 1.0 201 | 26 13 1.0 202 | 26 20 1.0 203 | 26 26 1.0 204 | 26 27 1.0 205 | 27 6 1.0 206 | 27 12 1.0 207 | 27 13 1.0 208 | 27 14 1.0 209 | 27 20 1.0 210 | 27 26 1.0 211 | 27 27 1.0 212 | 27 28 1.0 213 | 28 9 1.0 214 | 28 13 1.0 215 | 28 14 1.0 216 | 28 23 1.0 217 | 28 27 1.0 218 | 28 28 1.0 219 | 29 29 1.0 220 | 30 30 1.0 221 | 31 31 1.0 222 | 32 32 1.0 223 | 33 33 1.0 224 | 34 34 1.0 225 | 35 35 1.0 226 | 36 36 1.0 227 | 37 37 1.0 228 | 38 38 1.0 229 | 39 39 1.0 230 | 40 40 1.0 231 | 41 41 1.0 232 | 42 42 1.0 233 | -------------------------------------------------------------------------------- /Graphs/hess_pat_small.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CSCsw/ColPack/9a7293a8dfd66a60434496b8df5ebb4274d70339/Graphs/hess_pat_small.jpg -------------------------------------------------------------------------------- /Graphs/hess_pat_small.mtx: -------------------------------------------------------------------------------- 1 | %%MatrixMarket matrix coordinate real general 2 | 10 10 36 3 | 1 1 1 4 | 1 2 1 5 | 1 5 1 6 | 2 1 1 7 | 2 2 1 8 | 2 3 1 9 | 2 4 1 10 | 2 5 1 11 | 3 2 1 12 | 3 3 1 13 | 3 4 1 14 | 4 2 1 15 | 4 3 1 16 | 4 4 1 17 | 4 5 1 18 | 4 7 1 19 | 4 9 1 20 | 5 1 1 21 | 5 2 1 22 | 5 4 1 23 | 5 5 1 24 | 5 6 1 25 | 6 5 1 26 | 6 6 1 27 | 7 4 1 28 | 7 7 1 29 | 7 8 1 30 | 7 9 1 31 | 8 7 1 32 | 8 8 1 33 | 9 4 1 34 | 9 7 1 35 | 9 9 1 36 | 9 10 1 37 | 10 9 1 38 | 10 10 1 39 | -------------------------------------------------------------------------------- /Graphs/jac_pat.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CSCsw/ColPack/9a7293a8dfd66a60434496b8df5ebb4274d70339/Graphs/jac_pat.jpg -------------------------------------------------------------------------------- /Graphs/jac_pat.mtx: -------------------------------------------------------------------------------- 1 | %%MatrixMarket matrix coordinate real general 2 | 10 43 78 3 | 1 1 4 4 | 1 2 1 5 | 1 5 2 6 | 1 15 3 7 | 1 16 4 8 | 1 19 5 9 | 2 1 6 10 | 2 2 7 11 | 2 3 8 12 | 2 4 9 13 | 2 5 10 14 | 2 15 11 15 | 2 16 12 16 | 2 17 13 17 | 2 18 14 18 | 2 19 15 19 | 2 30 16 20 | 3 2 17 21 | 3 3 18 22 | 3 4 19 23 | 3 16 20 24 | 3 17 21 25 | 3 18 22 26 | 3 31 23 27 | 4 5 24 28 | 4 6 25 29 | 4 11 26 30 | 4 12 27 31 | 4 13 28 32 | 4 19 29 33 | 4 20 30 34 | 4 25 31 35 | 4 26 32 36 | 4 27 33 37 | 4 34 34 38 | 5 7 35 39 | 5 8 36 40 | 5 21 37 41 | 5 22 38 42 | 6 1 39 43 | 6 2 40 44 | 6 5 41 45 | 6 15 42 46 | 6 16 43 47 | 6 19 44 48 | 7 1 45 49 | 7 2 46 50 | 7 3 47 51 | 7 4 48 52 | 7 5 49 53 | 7 15 50 54 | 7 16 51 55 | 7 17 52 56 | 7 18 53 57 | 7 19 54 58 | 7 30 55 59 | 8 2 56 60 | 8 3 57 61 | 8 4 58 62 | 8 16 59 63 | 8 17 60 64 | 8 18 61 65 | 8 31 62 66 | 9 5 63 67 | 9 6 64 68 | 9 11 65 69 | 9 12 66 70 | 9 13 67 71 | 9 19 68 72 | 9 20 69 73 | 9 25 70 74 | 9 26 71 75 | 9 27 72 76 | 9 34 73 77 | 10 7 74 78 | 10 8 75 79 | 10 21 76 80 | 10 22 77 81 | -------------------------------------------------------------------------------- /Graphs/mtx-spear-head.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CSCsw/ColPack/9a7293a8dfd66a60434496b8df5ebb4274d70339/Graphs/mtx-spear-head.jpg -------------------------------------------------------------------------------- /Graphs/mtx-spear-head.mtx: -------------------------------------------------------------------------------- 1 | %%MatrixMarket matrix coordinate real general 2 | 10 10 28 3 | 1 1 .666666666666667 4 | 1 2 -6.310289677458059e-7 5 | 1 3 .283314888590275 6 | 1 4 .27224066696528 7 | 1 5 .666666666666667 8 | 1 6 .27224066696528 9 | 1 7 .666666666666667 10 | 1 8 .27224066696528 11 | 1 9 .666666666666667 12 | 1 10 .27224066696528 13 | 2 1 -6.310289677458059e-7 14 | 2 2 .27224066696528 15 | 3 1 .283314888590275 16 | 3 3 .577703998805546 17 | 4 1 .27224066696528 18 | 4 4 .283314888590275 19 | 5 1 .666666666666667 20 | 5 5 .283314888590275 21 | 6 1 .27224066696528 22 | 6 6 .283314888590275 23 | 7 1 .666666666666667 24 | 7 7 .283314888590275 25 | 8 1 .27224066696528 26 | 8 8 .283314888590275 27 | 9 1 .666666666666667 28 | 9 9 .283314888590275 29 | 10 1 .27224066696528 30 | 10 10 .283314888590275 31 | -------------------------------------------------------------------------------- /Graphs/mymatrix.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CSCsw/ColPack/9a7293a8dfd66a60434496b8df5ebb4274d70339/Graphs/mymatrix.jpg -------------------------------------------------------------------------------- /Graphs/mymatrix.mtx: -------------------------------------------------------------------------------- 1 | %%MatrixMarket matrix coordinate real general 2 | 3 6 8 3 | 1 1 2 4 | 1 2 1 5 | 1 4 -0.9823 6 | 1 5 -0.0071 7 | 2 3 2.1972 8 | 2 4 2.7726 9 | 3 5 3.6428 10 | 3 6 3.2721 -------------------------------------------------------------------------------- /Graphs/mymatrix1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CSCsw/ColPack/9a7293a8dfd66a60434496b8df5ebb4274d70339/Graphs/mymatrix1.jpg -------------------------------------------------------------------------------- /Graphs/mymatrix1.mtx: -------------------------------------------------------------------------------- 1 | %%MatrixMarket matrix coordinate real general 2 | 6 6 14 3 | 1 1 1.0 4 | 1 2 5.0 5 | 2 1 5.0 6 | 2 2 3.5985 7 | 2 5 -0.0536 8 | 3 3 1.8 9 | 3 5 6.0 10 | 4 4 -0.1835 11 | 5 2 -0.0536 12 | 5 3 6.0 13 | 5 5 -1.2988 14 | 5 6 -1.7023 15 | 6 5 -1.7023 16 | 6 6 5.9311 17 | -------------------------------------------------------------------------------- /Graphs/row-compress.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CSCsw/ColPack/9a7293a8dfd66a60434496b8df5ebb4274d70339/Graphs/row-compress.jpg -------------------------------------------------------------------------------- /Graphs/row-compress.mtx: -------------------------------------------------------------------------------- 1 | %%MatrixMarket matrix coordinate real general 2 | 10 10 19 3 | 1 1 .666666666666667 4 | 1 2 -6.310289677458059e-7 5 | 1 3 .283314888590275 6 | 1 4 .27224066696528 7 | 1 5 .666666666666667 8 | 1 6 .27224066696528 9 | 1 7 .666666666666667 10 | 1 8 .27224066696528 11 | 1 9 .666666666666667 12 | 1 10 .27224066696528 13 | 2 2 .27224066696528 14 | 3 3 .577703998805546 15 | 4 4 .283314888590275 16 | 5 5 .283314888590275 17 | 6 6 .283314888590275 18 | 7 7 .283314888590275 19 | 8 8 .283314888590275 20 | 9 9 .283314888590275 21 | 10 10 .283314888590275 22 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2018, Alex Pothen 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | * Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /build/automake/configure.ac: -------------------------------------------------------------------------------- 1 | /************************************************************************************ 2 | Copyright (C) 2005-2008 Assefaw H. Gebremedhin, Arijit Tarafdar, Duc Nguyen, 3 | Alex Pothen 4 | 5 | This file is part of ColPack. 6 | 7 | ColPack is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published 9 | by the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version.GraphColoring::GraphColoring() 11 | 12 | ColPack is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with ColPack. If not, see . 19 | ************************************************************************************/ 20 | 21 | define([COLPACK_VER], [1]) 22 | define([COLPACK_SUB], [0]) 23 | define([COLPACK_LVL], [10]) 24 | define([COLPACK_ROOT_DIR],[../..]) 25 | 26 | AC_INIT([ColPack],[COLPACK_VER.COLPACK_SUB.COLPACK_LVL],[assefaw@eecs.wsu.edu],[ColPack],[http://cscapes.cs.purdue.edu/coloringpage/]) 27 | AC_PREREQ([2.57]) 28 | : ${CXXFLAGS=-O3} 29 | : ${CFLAGS=-O3} 30 | AC_CONFIG_SRCDIR([../../inc/ColPackHeaders.h]) 31 | AC_CONFIG_MACRO_DIR([m4]) 32 | AM_INIT_AUTOMAKE([foreign 1.10 no-define subdir-objects -Wall]) 33 | AM_SILENT_RULES([yes]) 34 | AC_CONFIG_HEADERS(config.h) 35 | AC_PROG_CXX 36 | AX_CXXFLAGS_WARN_ALL 37 | AC_CONFIG_FILES(Makefile) 38 | AM_PROG_AR 39 | LT_INIT 40 | 41 | AC_MSG_CHECKING(Build examples) 42 | AC_ARG_ENABLE([examples], 43 | [AS_HELP_STRING([--enable-examples],[Build examples])], 44 | [case "${enableval}" in 45 | yes) examples=true ;; 46 | no) examples=false ;; 47 | *) AC_MSG_ERROR([bad value ${enableval} for --enable-examples]) ;; 48 | esac],[examples=false]) 49 | AM_CONDITIONAL([EXAMPLES], [test x$examples = xtrue]) 50 | 51 | AC_MSG_CHECKING(OpenMP) 52 | AC_ARG_ENABLE([openmp], 53 | [AS_HELP_STRING([--disable-openmp],[Disable OpenMP])], 54 | [case "${enableval}" in 55 | yes) openmp=true ;; 56 | no) openmp=false ;; 57 | *) AC_MSG_ERROR([bad value ${enableval} for --disable-openmp]) ;; 58 | esac],[openmp=true]) 59 | AM_CONDITIONAL([ENABLE_OPENMP], [test x$openmp = xtrue]) 60 | 61 | AC_OUTPUT 62 | 63 | # echo configuration 64 | echo \ 65 | " 66 | ----------------------------------------------------------------------------- 67 | Configuration: 68 | 69 | C compiler: ${CC} 70 | C++ compiler: ${CXX} 71 | Linker: ${LD} 72 | Automake Source code location: `pwd` 73 | Install path: ${prefix} 74 | 75 | CFLAGS: ${CFLAGS} 76 | CXXFLAGS: ${CXXFLAGS} 77 | 78 | Use OpenMP: ${openmp} 79 | Build examples: ${examples} 80 | 81 | cx 82 | top_srcdir ${top_srcdir} 83 | ----------------------------------------------------------------------------- 84 | " 85 | -------------------------------------------------------------------------------- /build/cmake/ColPackConfig.cmake.in: -------------------------------------------------------------------------------- 1 | # This file is configured by CMake and installed into ColPack's installation. 2 | # It is used by downstream (client) projects when they use 3 | # find_package(ColPack) in their CMakeLists.txt. We define variables that 4 | # may be useful to users and include the file that defines ColPack's targets. 5 | # CMake will replace all variables surrounded with "at" symbols by their value. 6 | # 7 | # For downstream users: the available targets are: 8 | # - ColPack_shared (for a shared library) 9 | # - ColPack_static (for a static library) 10 | @PACKAGE_INIT@ 11 | set(ColPack_VERSION @COLPACK_VERSION@) 12 | set_and_check(ColPack_ROOT_DIR "@PACKAGE_CMAKE_INSTALL_PREFIX@") 13 | include("${CMAKE_CURRENT_LIST_DIR}/ColPackTargets.cmake") 14 | -------------------------------------------------------------------------------- /goingToBeRemoved/NEWS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CSCsw/ColPack/9a7293a8dfd66a60434496b8df5ebb4274d70339/goingToBeRemoved/NEWS -------------------------------------------------------------------------------- /goingToBeRemoved/autoconf.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh -ev 2 | 3 | autoreconf --force --install 4 | 5 | ./configure --prefix=$(pwd)/build --exec-prefix=$(pwd)/build --enable-examples 6 | 7 | if [ -z "$NCPU" ]; then 8 | NCPU=$(lscpu --parse | egrep -v '^#' | wc -l || echo 1) 9 | fi 10 | echo "NCPU=${NCPU}" 11 | if [ -z "$MAKEFLAGS" ]; then 12 | export MAKEFLAGS=-j${NCPU} 13 | fi 14 | echo "MAKEFLAGS=${MAKEFLAGS}" 15 | 16 | make clean 17 | 18 | make EXTRA_FLAGS="-O5 -DCOLPACK_DEBUG_LEVEL=0" 19 | 20 | exit 0 21 | 22 | # Alternative configuration: 23 | 24 | # ./configure --prefix=$(pwd)/build --exec-prefix=$(pwd)/build --enable-examples --enable-openmp 25 | 26 | # Misc commentary. 27 | 28 | # The sh -e option exits on failure, avoiding the need to guard commands. 29 | 30 | # The sh -v option echos commands before executing them, avoiding the 31 | # need to do so manually. 32 | 33 | # I'm dubious about 34 | # (a) invoking "make" here at all, 35 | # (b) using make option -j instead of leaving that to the user, via ${MAKEFLAGS}, 36 | # (c) using make option -j instead of -jX where X = #CPUs. 37 | # The "if" stanza addresses (c), and partially addresses (b) by avoiding overriding 38 | # or augmenting ${MAKEFLAGS} if it is already set. 39 | -------------------------------------------------------------------------------- /goingToBeRemoved/main_page.txt: -------------------------------------------------------------------------------- 1 | /*! \mainpage ColPack 2 | * 3 | *

Assefaw H. Gebremedhin, Duc Nguyen, Arijit Tarafdar, Md. Mostofa Ali Patwary, Alex Pothen

4 | * 5 | * \section INTRODUCTION 6 | * 7 | * ColPack is a package comprising of implementation of algorithms for specialized vertex coloring problems 8 | * that arise in sparse derivative computation. It is written in an object-oriented fashion heavily using 9 | * the Standard Template Library (STL). It is designed to be simple, modular, extenable and efficient. 10 | * 11 | * \section SAMPLE_CODES SAMPLE CODES 12 | * 13 | * Sample codes (with comments) that quickly illustrate how ColPack interface functions are used 14 | * are available in the directory SampleDriver.
15 | * Click on "Files" tab and then pick the files you want to look at and click on the [code] link.
16 | *
17 | * To compile all sample drivers on UNIX: make test
18 | * To run all sample drivers on UNIX: make run-test
19 | * Notes:
20 | * - The make command could also be run with parameters: "make EXECUTABLE=(desired name. Optional, default name is ColPack) INSTALL_DIR=(directory where the compiled program will be placed. Optional, default dir is ./)". 21 | * - On multi-processors computer, add flag "-j" for faster result. 22 | * 23 | * \section DOWNLOAD 24 | * 25 | * ColPack
26 | * Graph Collection in Matrix Market format
27 | * Graph Collection in MeTis format
28 | * To decompress .zip files on UNIX, run "unzip (targeted .zip file)"
29 | * 30 | * \section CONTACT 31 | * 32 | * Email Assefaw Gebremedhin at agebreme [at] purdue [dot] edu or Duc Nguyen at nguyend [at] purdue [dot] edu . 33 | * 34 | */ 35 | 36 | /** @defgroup group1 Classes for Graphs 37 | Based on functionalities, the general graph coloring part of ColPack is divided into five classes - 38 | GraphCore, GraphInputOutput, GraphOrdering, GraphColoring and GraphColoringInterface. In the 39 | methods described below if no return type is specifed, it would be an int by default. Most ColPack 40 | methods return TRUE on success, which has an integer value of 1. 41 | */ 42 | 43 | /** 44 | * @defgroup group2 Classes for Bipartite Graphs 45 | */ 46 | 47 | /** @defgroup group21 Classes for Bipartite Graphs Partial Coloring 48 | * @ingroup group2 49 | */ 50 | 51 | /** @defgroup group22 Classes for Bipartite Graphs BiColoring 52 | * @ingroup group2 53 | */ 54 | 55 | /** @defgroup group5 Recovery Classes 56 | */ 57 | 58 | /** @defgroup group4 Auxiliary Classes 59 | */ 60 | 61 | -------------------------------------------------------------------------------- /goingToBeRemoved/previous_license_head: -------------------------------------------------------------------------------- 1 | /************************************************************************************ 2 | Copyright (C) 2005-2008 Assefaw H. Gebremedhin, Arijit Tarafdar, Duc Nguyen, 3 | Alex Pothen 4 | 5 | This file is part of ColPack. 6 | 7 | ColPack is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published 9 | by the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | ColPack is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with ColPack. If not, see . 19 | ************************************************************************************/ 20 | -------------------------------------------------------------------------------- /inc/ColPackHeaders.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | This file is part of ColPack, which is under its License protection. 3 | You should have received a copy of the License. If not, see 4 | 5 | *******************************************************************************/ 6 | 7 | /************************************************************************************/ 8 | /* */ 9 | /* Headers.h (Header of header files) */ 10 | /* */ 11 | /************************************************************************************/ 12 | #ifndef HEADER_H 13 | #define HEADER_H 14 | 15 | #include "Definitions.h" 16 | 17 | #ifdef SYSTEM_TIME 18 | 19 | #include 20 | 21 | #else 22 | 23 | #include 24 | 25 | #endif 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | #include 43 | #include 44 | #include //for pair 45 | 46 | #ifdef _OPENMP 47 | #include 48 | #endif 49 | 50 | #include "Pause.h" 51 | #include "File.h" 52 | #include "Timer.h" 53 | #include "MatrixDeallocation.h" 54 | #include "mmio.h" 55 | #include "current_time.h" 56 | #include "CoutLock.h" 57 | 58 | #include "StringTokenizer.h" 59 | #include "DisjointSets.h" 60 | 61 | #include "GraphCore.h" 62 | #include "GraphInputOutput.h" 63 | #include "GraphOrdering.h" 64 | #include "GraphColoring.h" 65 | #include "GraphColoringInterface.h" 66 | 67 | #include "BipartiteGraphCore.h" 68 | #include "BipartiteGraphInputOutput.h" 69 | #include "BipartiteGraphVertexCover.h" 70 | #include "BipartiteGraphPartialOrdering.h" 71 | #include "BipartiteGraphOrdering.h" 72 | #include "BipartiteGraphBicoloring.h" 73 | #include "BipartiteGraphPartialColoring.h" 74 | #include "BipartiteGraphBicoloringInterface.h" 75 | #include "BipartiteGraphPartialColoringInterface.h" 76 | 77 | #include "RecoveryCore.h" 78 | #include "HessianRecovery.h" 79 | #include "JacobianRecovery1D.h" 80 | #include "JacobianRecovery2D.h" 81 | 82 | #include "extra.h" 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /inc/Definitions.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | This file is part of ColPack, which is under its License protection. 3 | You should have received a copy of the License. If not, see 4 | 5 | *******************************************************************************/ 6 | 7 | /******************************************************************************/ 8 | /* */ 9 | /*DEBUG and ERROR Counter Ranges: (OBSOLETE) */ 10 | /* */ 11 | /*GraphCore 1100:1199 */ 12 | /*GraphInputOutput 1200:1299 */ 13 | /*GraphOrdering 1300:1399 */ 14 | /*GraphColoring 1400:1499 */ 15 | /*GraphColoringInterface 1500:1699 */ 16 | /* */ 17 | /*BipartiteGraphCore 2100:2199;3100:3199 */ 18 | /*BipartiteGraphInputOutput 2200:2299;3200:3299 */ 19 | /*BipartiteGraphPartialOrdering 2300:2399 */ 20 | /*BipartiteGraphPartialColoring 2400:2499 */ 21 | /*BipartiteGraphPartialColoringInterface 2500:2699 */ 22 | /* */ 23 | /*BipartiteGraphCovering 3300:3399 */ 24 | /*BipartiteGraphOrdering 3400:3499 */ 25 | /*BipartiteGraphBicoloring 3500:3599 */ 26 | /*BipartiteGraphBicoloringInterface 3600:3799 */ 27 | /* */ 28 | /*StringTokenizer 4100:4199 */ 29 | /*DisjointSets 4200:4299 */ 30 | /*Timer 4300:4399 */ 31 | /* */ 32 | /*HessianMatrix 5100:5199 */ 33 | /******************************************************************************/ 34 | 35 | #ifndef DEFINITION_H 36 | #define DEFINITION_H 37 | 38 | #if defined (_WIN32) || defined (__WIN32) || defined (__WIN32__) || defined (WIN32) //Windows OS Predefined Macros 39 | #define ____WINDOWS_OS____ 40 | #endif 41 | 42 | #define STEP_DOWN(INPUT) ((INPUT) - 1) 43 | #define STEP_UP(INPUT) ((INPUT) + 1) 44 | 45 | #define _INVALID -2 46 | #define _UNKNOWN -1 47 | #define _FALSE 0 48 | #define _TRUE 1 49 | 50 | #define _OFF 0 51 | #define _ON 1 52 | 53 | #define DISJOINT_SETS _TRUE 54 | 55 | #define STATISTICS _TRUE 56 | 57 | #ifndef ____WINDOWS_OS____ 58 | /// UNIX only. Used to measure longer execution time. 59 | /** Define SYSTEM_TIME to measure the execution time of a program which may run for more than 30 minutes 60 | (35.79 minutes or 2,147 seconds to be accurate) 61 | Reason: In UNIX, CLOCKS_PER_SEC is defined to be 1,000,000 (In Windows, CLOCKS_PER_SEC == 1,000). 62 | The # of clock-ticks is measured by using variables of type int => max value is 2,147,483,648. 63 | Time in seconds = # of clock-ticks / CLOCKS_PER_SEC => max Time in seconds = 2,147,483,648 / 1,000,000 ~= 2,147 64 | */ 65 | #define SYSTEM_TIME 66 | #else 67 | #undef SYSTEM_TIME 68 | #endif 69 | 70 | //define system-dependent directory separator 71 | #ifndef ____WINDOWS_OS____ 72 | #define DIR_SEPARATOR "/" 73 | #else 74 | #define DIR_SEPARATOR "\\" 75 | #endif 76 | 77 | //#define DEBUG _UNKNOWN 78 | //#define DEBUG 5103 79 | 80 | // definition for variadic Graph...Interface() 81 | #define SRC_WAIT -1 82 | #define SRC_FILE 0 83 | #define SRC_MEM_ADOLC 1 84 | #define SRC_MEM_ADIC 2 85 | #define SRC_MEM_SSF 3 86 | #define SRC_MEM_CSR 4 87 | 88 | 89 | enum boolean {FALSE=0, TRUE}; 90 | 91 | //enum _INPUT_FORMAT {MATRIX_MARKET, METIS, HARWELL_BOEING}; 92 | 93 | //enum _VERTEX_ORDER {NATURAL, LARGEST_FIRST, DYNAMIC_LARGEST_FIRST, DISTANCE_TWO_LARGEST_FIRST, SMALLEST_LAST, DISTANCE_TWO_SMALLEST_LAST, INCIDENCE_DEGREE, DISTANCE_TWO_INCIDENCE_DEGREE}; 94 | 95 | //enum _COLORING_STYLE {DISTANCE_ONE, DISTANCE_TWO, NAIVE_STAR, RESTRICTED_STAR, STAR, ACYCLIC, TRIANGULAR}; 96 | 97 | //enum _BIPARTITE_VERTEX_ORDER{NATURAL, LARGEST_FIRST, SELECTIVE_LARGEST_FIRST, DYNAMIC_LARGEST_FIRST, ROW_LARGEST_FIRST, COLUMN_LARGEST_FIRST, SMALLEST_LAST, SELECTIVE_SMALLEST_LAST, ROW_SMALLEST_LAST, COLUMN_SMALLEST_LAST, INCIDENCE_DEGREE, SELECTIVE_INCIDENCE_DEGREE, ROW_INCIDENCE_DEGREE, COLUMN_INCIDENCE_DEGREE}; 98 | 99 | //enum _BIPARTITE_COLORING_STYLE{ROW_PARTIAL_DISTANCE_TWO, COLUMN_PARTIAL_DISTANCE_TWO, LEFT_STAR, RIGHT_STAR, MINIMAL_COVER_STAR, MINIMAL_COVER_MODIFIED_STAR, IMPLICIT_COVER_STAR, IMPLICT_COVER_CONSERVATIVE_STAR, IMPLICIT_COVER_RESTRICTED_STAR, IMPLICIT_COVER_GREEDY_STAR, IMPLICIT_COVER_ACYCLIC}; 100 | 101 | #endif 102 | -------------------------------------------------------------------------------- /src/BipartiteGraphBicoloring/BipartiteGraphCore.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | This file is part of ColPack, which is under its License protection. 3 | You should have received a copy of the License. If not, see 4 | 5 | *******************************************************************************/ 6 | 7 | using namespace std; 8 | 9 | #ifndef BIPARTITEGRAPHCORE_H 10 | #define BIPARTITEGRAPHCORE_H 11 | 12 | namespace ColPack 13 | { 14 | /** @ingroup group2 15 | * @brief class BipartiteGraphCore in @link group2@endlink. 16 | 17 | Base class for Bipartite Graph. Define a Bipartite Graph: left vertices, right vertices and edges; and its statisitcs: max, min and average degree. 18 | */ 19 | class BipartiteGraphCore 20 | { 21 | public: //DOCUMENTED 22 | 23 | /// LeftVertexCount = RowVertexCount = m_vi_LeftVertices.size() -1 24 | int GetRowVertexCount(); 25 | /// LeftVertexCount = RowVertexCount = m_vi_LeftVertices.size() -1 26 | int GetLeftVertexCount(); 27 | 28 | 29 | /// RightVertexCount = ColumnVertexCount = m_vi_RightVertices.size() -1 30 | int GetColumnVertexCount(); 31 | /// RightVertexCount = ColumnVertexCount = m_vi_RightVertices.size() -1 32 | int GetRightVertexCount(); 33 | 34 | bool operator==(const BipartiteGraphCore &other) const; 35 | 36 | protected: 37 | 38 | int m_i_MaximumLeftVertexDegree; 39 | int m_i_MaximumRightVertexDegree; 40 | int m_i_MaximumVertexDegree; 41 | 42 | int m_i_MinimumLeftVertexDegree; 43 | int m_i_MinimumRightVertexDegree; 44 | int m_i_MinimumVertexDegree; 45 | 46 | double m_d_AverageLeftVertexDegree; 47 | double m_d_AverageRightVertexDegree; 48 | double m_d_AverageVertexDegree; 49 | 50 | string m_s_InputFile; 51 | 52 | vector m_vi_LeftVertices; 53 | vector m_vi_RightVertices; 54 | 55 | vector m_vi_Edges; 56 | 57 | map< int, map > m_mimi2_VertexEdgeMap; 58 | 59 | 60 | public: 61 | 62 | virtual ~BipartiteGraphCore(){} 63 | 64 | virtual void Clear(); 65 | 66 | string GetInputFile(); 67 | 68 | vector* GetLeftVerticesPtr() ; 69 | vector* GetRightVerticesPtr() ; 70 | 71 | const vector& GetLeftVertices() const { return m_vi_LeftVertices; } 72 | const vector& GetRightVertices() const { return m_vi_RightVertices;} 73 | const int GetMaximumLeftVertexDegree() const { return m_i_MaximumLeftVertexDegree; } 74 | const int GetMaximumRightVertexDegree() const { return m_i_MaximumRightVertexDegree; } 75 | const vector& GetEdges() const { return m_vi_Edges; } 76 | void GetRowVertices(vector &output) const; 77 | void GetLeftVertices(vector &output) const; 78 | 79 | void GetColumnVertices(vector &output) const; 80 | void GetRightVertices(vector &output) const; 81 | 82 | unsigned int GetRowVertices(unsigned int** ip2_RowVertex); 83 | unsigned int GetColumnIndices(unsigned int** ip2_ColumnIndex); 84 | 85 | void GetEdges(vector &output) const; 86 | 87 | void GetVertexEdgeMap(map< int, map > &output); 88 | 89 | int GetEdgeCount(); 90 | 91 | int GetMaximumRowVertexDegree(); 92 | 93 | 94 | int GetMaximumColumnVertexDegree(); 95 | 96 | int GetMaximumVertexDegree(); 97 | 98 | int GetMinimumRowVertexDegree(); 99 | 100 | int GetMinimumColumnVertexDegree(); 101 | 102 | int GetMinimumVertexDegree(); 103 | 104 | double GetAverageRowVertexDegree(); 105 | 106 | double GetAverageColumnVertexDegree(); 107 | 108 | double GetAverageVertexDegree(); 109 | }; 110 | } 111 | #endif 112 | -------------------------------------------------------------------------------- /src/BipartiteGraphBicoloring/BipartiteGraphOrdering.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | This file is part of ColPack, which is under its License protection. 3 | You should have received a copy of the License. If not, see 4 | 5 | *******************************************************************************/ 6 | 7 | //using namespace std; 8 | 9 | #ifndef BIPARTITEGRAPHORDERING_H 10 | #define BIPARTITEGRAPHORDERING_H 11 | 12 | using namespace std; 13 | 14 | namespace ColPack 15 | { 16 | /** @ingroup group22 17 | * @brief class BipartiteGraphOrdering in @link group22@endlink. 18 | 19 | The BipartiteGraphOrderingClass stores the ordered row and column vertices as a vector of vertex 20 | identifiers to be used by bipartite graph bicoloring methods. Since the row and column vertices use the same 21 | set of identifiers, number of row vertices is added the column vertex identifiers in the ordered vector. 22 | */ 23 | class BipartiteGraphOrdering : public BipartiteGraphVertexCover 24 | { 25 | public: 26 | 27 | int OrderVertices(string s_OrderingVariant); 28 | 29 | private: 30 | 31 | //Private Function 3401 32 | int CheckVertexOrdering(string s_VertexOrderingVariant); 33 | 34 | protected: 35 | 36 | double m_d_OrderingTime; 37 | 38 | string m_s_VertexOrderingVariant; 39 | 40 | vector m_vi_OrderedVertices; 41 | 42 | public: 43 | 44 | BipartiteGraphOrdering(); 45 | 46 | ~BipartiteGraphOrdering(); 47 | 48 | virtual void Clear(); 49 | 50 | virtual void Reset(); 51 | 52 | int NaturalOrdering(); 53 | 54 | int RandomOrdering(); 55 | 56 | int LargestFirstOrdering(); 57 | 58 | int SmallestLastOrdering(); 59 | 60 | int IncidenceDegreeOrdering(); 61 | 62 | int DynamicLargestFirstOrdering(); 63 | 64 | int SelectiveLargestFirstOrdering(); 65 | 66 | int SelectiveSmallestLastOrdering(); 67 | 68 | int SelectiveIncidenceDegreeOrdering(); 69 | 70 | string GetVertexOrderingVariant(); 71 | 72 | void GetOrderedVertices(vector &output); 73 | 74 | void PrintVertexOrdering(); 75 | 76 | double GetVertexOrderingTime(); 77 | }; 78 | } 79 | #endif 80 | -------------------------------------------------------------------------------- /src/BipartiteGraphBicoloring/BipartiteGraphVertexCover.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | This file is part of ColPack, which is under its License protection. 3 | You should have received a copy of the License. If not, see 4 | 5 | *******************************************************************************/ 6 | 7 | using namespace std; 8 | 9 | #ifndef BIPARTITEGRAPHVERTEXCOVER_H 10 | #define BIPARTITEGRAPHVERTEXCOVER_H 11 | 12 | namespace ColPack 13 | { 14 | /** @ingroup group22 15 | * @brief class BipartiteGraphVertexCover in @link group22@endlink. 16 | 17 | The bipartite graph bicoloring algorithms included in ColPack are variations of greedy, star and 18 | acyclic bicolorings combined with explicit and implicit vertex coverings and guided by pre-computed vertex 19 | orderings. The row and column vertices are initalized with two default colors, which are generally the color 0 20 | for row vertices and for column vertices the color equal to one more than the sum of the numbers of row and 21 | column vertices. The vertices whose colors are subsequently changed by the algorithms constitute a vertex 22 | cover for the bipartite graph. The goal is to get the smallest vertex cover that can be colored to conform to 23 | the bicoloring constraints. The computation of vertex cover has given rise to two types of algorithms, in one 24 | of which a specialized vertex cover is computed explicitly for consumption by bicoloring algorithms and in 25 | the other implicitly within the bicoloring algorithms. The bipartite graph covering class provides methods 26 | for explicitly computing these specialized vertex covers. 27 | */ 28 | class BipartiteGraphVertexCover : public BipartiteGraphInputOutput 29 | { 30 | 31 | protected: 32 | 33 | double m_d_CoveringTime; 34 | 35 | vector m_vi_IncludedLeftVertices; 36 | vector m_vi_IncludedRightVertices; 37 | 38 | vector m_vi_CoveredLeftVertices; 39 | vector m_vi_CoveredRightVertices; 40 | 41 | public: 42 | 43 | //Public Constructor 3351 44 | BipartiteGraphVertexCover(); 45 | 46 | //Public Destructor 3352 47 | ~BipartiteGraphVertexCover(); 48 | 49 | //Virtual Function 3353 50 | virtual void Clear(); 51 | 52 | //Virtual Function 3354 53 | virtual void Reset(); 54 | 55 | //Public Function 3355 56 | int CoverVertex(); 57 | 58 | //Public Function 3356 59 | int CoverVertex(vector &); 60 | 61 | //Public Function 3357 62 | int CoverMinimalVertex(); 63 | 64 | //Public Function 3358 65 | void GetIncludedLeftVertices(vector &output); 66 | 67 | //Public Function 3359 68 | void GetIncludedRightVertices(vector &output); 69 | 70 | //Public Function 3360 71 | void GetCoveredLeftVertices(vector &output); 72 | 73 | //Public Function 3361 74 | void GetCoveredRightVertices(vector &output); 75 | 76 | //Public Function 3362 77 | void PrintBicoloringVertexCover(); 78 | 79 | }; 80 | } 81 | #endif 82 | -------------------------------------------------------------------------------- /src/BipartiteGraphPartialColoring/BipartiteGraphPartialOrdering.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | This file is part of ColPack, which is under its License protection. 3 | You should have received a copy of the License. If not, see 4 | 5 | *******************************************************************************/ 6 | 7 | using namespace std; 8 | 9 | #ifndef BIPARTITEGRAPHPARTIALORDERING_H 10 | #define BIPARTITEGRAPHPARTIALORDERING_H 11 | 12 | #define RIGHT_PARTIAL_DISTANCE_TWO COLUMN_PARTIAL_DISTANCE_TWO 13 | #define LEFT_PARTIAL_DISTANCE_TWO ROW_PARTIAL_DISTANCE_TWO 14 | 15 | namespace ColPack 16 | { 17 | /** @ingroup group21 18 | * @brief class BipartiteGraphPartialOrdering in @link group21@endlink. 19 | 20 | The BipartiteGraphPartialOrderingClass stores either the ordered row or column vertices as a 21 | vector of vertex identifiers to be used by bipartite graph partial coloring methods. 22 | */ 23 | class BipartiteGraphPartialOrdering : public BipartiteGraphInputOutput 24 | { 25 | public: 26 | 27 | int OrderVertices(string s_OrderingVariant = "NATURAL", string s_ColoringVariant = "COLUMN_PARTIAL_DISTANCE_TWO"); 28 | 29 | private: 30 | 31 | int CheckVertexOrdering(string s_VertexOrderingVariant); 32 | 33 | protected: 34 | 35 | double m_d_OrderingTime; 36 | 37 | string m_s_VertexOrderingVariant; 38 | 39 | vector m_vi_OrderedVertices; 40 | 41 | public: 42 | 43 | BipartiteGraphPartialOrdering(); 44 | 45 | ~BipartiteGraphPartialOrdering(); 46 | 47 | virtual void Clear(); 48 | 49 | virtual void Reset(); 50 | 51 | int RowNaturalOrdering(); 52 | int ColumnNaturalOrdering(); 53 | 54 | int RowRandomOrdering(); 55 | int ColumnRandomOrdering(); 56 | 57 | int RowLargestFirstOrdering(); 58 | int ColumnLargestFirstOrdering(); 59 | 60 | int RowSmallestLastOrdering(); 61 | int RowSmallestLastOrdering_serial(); 62 | int RowSmallestLastOrdering_OMP(); 63 | int ColumnSmallestLastOrdering(); 64 | int ColumnSmallestLastOrdering_serial(); 65 | int ColumnSmallestLastOrdering_OMP(); 66 | 67 | int RowIncidenceDegreeOrdering(); 68 | int ColumnIncidenceDegreeOrdering(); 69 | 70 | int RowDynamicLargestFirstOrdering(); 71 | int ColumnDynamicLargestFirstOrdering(); 72 | 73 | string GetVertexOrderingVariant(); 74 | 75 | void GetOrderedVertices(vector &output); 76 | 77 | void PrintVertexOrdering(); 78 | 79 | double GetVertexOrderingTime(); 80 | }; 81 | } 82 | #endif 83 | -------------------------------------------------------------------------------- /src/GeneralGraphColoring/GraphCore.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | This file is part of ColPack, which is under its License protection. 3 | You should have received a copy of the License. If not, see 4 | 5 | *******************************************************************************/ 6 | 7 | using namespace std; 8 | 9 | #ifndef GRAPHCORE_H 10 | #define GRAPHCORE_H 11 | namespace ColPack 12 | { 13 | /** @ingroup group1 14 | * @brief class GraphCore in @link group1@endlink. 15 | 16 | Base class for Graph. Define a Graph: vertices, edges and values (edge's weight - optional); and its statisitcs: max, min and average degree. 17 | */ 18 | class GraphCore 19 | { 20 | public: //DOCUMENTED 21 | 22 | ///Print all the Distance-1 neighbors of VertexIndex (0-based), except the excludedVertex 23 | void PrintVertexD1Neighbor(int VertexIndex, int excludedVertex = -1); 24 | void GetD1Neighbor(int VertexIndex, vector &D1Neighbor, int excludedVertex = -1); 25 | 26 | /// Print all the Distance-2 neighbors of VertexIndex 27 | void PrintVertexD2Neighbor(int VertexIndex); 28 | 29 | /// Check and see if VertexIndex1 and VertexIndex2 are Distance-2 neighbor 30 | /** Algorithm: 31 | - Get the set D1_of_VertexIndex1 of all the Distance-1 neighbors of VertexIndex1 32 | - Get the set D1_of_VertexIndex2 of all the Distance-1 neighbors of VertexIndex2 33 | - Intersect D1_of_VertexIndex1 and D1_of_VertexIndex2 to see which vertices VertexIndex1 and VertexIndex2 have in common. The result is stored in Intersect_set 34 | - If the size of Intersect_set > 0 => VertexIndex1 and VertexIndex2 are Distance-2 neighbor 35 | */ 36 | bool AreD2Neighbor(int VertexIndex1, int VertexIndex2); 37 | 38 | bool operator==(const GraphCore &other) const; 39 | bool areEqual(const GraphCore &other, bool structureOnly = 1) const; 40 | 41 | protected: 42 | 43 | int m_i_MaximumVertexDegree; 44 | int m_i_MinimumVertexDegree; 45 | 46 | double m_d_AverageVertexDegree; 47 | 48 | string m_s_InputFile; 49 | 50 | vector m_vi_Vertices; 51 | 52 | vector m_vi_Edges; 53 | 54 | vector m_vd_Values; //!< Edge's weight 55 | 56 | /** m_mimi2_VertexEdgeMap is a matrix that has all the non-zero (edge) in the 57 | upper triangle marked from 0 to (total number of non-zeros - 1) 58 | Populated by GraphColoring::AcyclicColoring() 59 | */ 60 | map< int, map< int, int> > m_mimi2_VertexEdgeMap; //moved from int GraphColoring::AcyclicColoring() 61 | 62 | /** m_ds_DisjointSets holds a set of bi-color trees 63 | Populated by GraphColoring::AcyclicColoring() 64 | */ 65 | DisjointSets m_ds_DisjointSets; //moved from int GraphColoring::AcyclicColoring() 66 | public: 67 | 68 | virtual ~GraphCore() {} 69 | 70 | virtual void Clear(); 71 | 72 | int GetVertexCount(); 73 | 74 | int GetEdgeCount(); 75 | 76 | int GetMaximumVertexDegree(); 77 | 78 | int GetMinimumVertexDegree(); 79 | 80 | double GetAverageVertexDegree(); 81 | 82 | string GetInputFile(); 83 | 84 | void GetVertices(vector &output) const; 85 | vector * GetVerticesPtr(){ return &m_vi_Vertices; } 86 | 87 | void GetEdges(vector &output) const; 88 | vector * GetEdgesPtr(){ return &m_vi_Edges; } 89 | 90 | void GetValues(vector &output) const; 91 | 92 | void GetVertexEdgeMap(map< int, map< int, int> > &output); 93 | 94 | void GetDisjointSets(DisjointSets &output); 95 | 96 | 97 | }; 98 | } 99 | #endif 100 | 101 | -------------------------------------------------------------------------------- /src/GeneralGraphColoring/GraphInputOutput.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | This file is part of ColPack, which is under its License protection. 3 | You should have received a copy of the License. If not, see 4 | 5 | *******************************************************************************/ 6 | 7 | #ifndef GRAPHINPUTOUTPUT_H 8 | #define GRAPHINPUTOUTPUT_H 9 | 10 | using namespace std; 11 | 12 | namespace ColPack 13 | { 14 | /** @ingroup group1 15 | * @brief class GraphInputOutput in @link group1@endlink. 16 | 17 | This class provides the input methods for reading in matrix or graph files in supported 18 | formats for generating general graphs. Three input formats are supported by default - Matrix Market, 19 | Harwell Boeing and MeTiS. 20 | */ 21 | class GraphInputOutput : public GraphCore 22 | { 23 | public: 24 | 25 | /// Read the sparsity pattern of Hessian matrix represented in ADOLC format (Compressed Sparse Row format) and build a corresponding adjacency graph. 26 | /** 27 | Precondition: 28 | - The Hessian matrix must be stored in Row Compressed Format 29 | 30 | Return value: 31 | - i_HighestDegree 32 | */ 33 | int BuildGraphFromRowCompressedFormat(unsigned int ** uip2_HessianSparsityPattern, int i_RowCount); 34 | 35 | /// Read the sparsity pattern of a symmetric matrix in the specified file format from the specified filename and build an adjacency graph. 36 | /** This function will 37 | - 1. Read the name of the matrix file and decide which matrix format the file used (based on the file extension). If the file name has no extension, the user will need to pass the 2nd parameter "fileType" explicitly to tell ColPack which matrix format is used 38 | - 2. Call the corresponding reading routine to build the graph 39 | 40 | About input parameters: 41 | - fileName: name of the input file for a symmetric matrix. If the full path is not given, the file is assumed to be in the current directory 42 | - fileType can be either 43 | - "AUTO_DETECTED" (default) or "". ColPack will decide the format of the file based on the file extension: 44 | - ".mtx": symmetric MatrixMarket format 45 | - ".hb", or any combination of ".": HarwellBoeing format 46 | - ".graph": MeTiS format 47 | - If the above extensions are not found, MatrixMarket format will be assumed. 48 | - "MM" for MatrixMarket format (http://math.nist.gov/MatrixMarket/formats.html#MMformat). Notes: 49 | - ColPack only accepts MatrixMarket coordinate format (NO array format) 50 | - List of arithmetic fields accepted by ColPack: real, pattern or integer 51 | - List of symmetry structures accepted by ColPack: general or symmetric 52 | - The first line of the input file should be similar to this: "%%MatrixMarket matrix coordinate real general" 53 | - "HB" for HarwellBoeing format (http://math.nist.gov/MatrixMarket/formats.html#hb) 54 | - "MeTiS" for MeTiS format (http://people.sc.fsu.edu/~burkardt/data/metis_graph/metis_graph.html) 55 | */ 56 | int ReadAdjacencyGraph(string s_InputFile, string s_fileFormat="AUTO_DETECTED"); 57 | 58 | // !!! NEED TO BE FIXED 59 | /// Read the entries of a symmetric matrix in Matrix Market format and build the corresponding adjacency graph 60 | /** 61 | Precondition: 62 | - s_InputFile should point to the MatrixMarket-format input file (file name usually ends with .mtx) 63 | - If (b_getStructureOnly == true) only the structure of the matrix is read. 64 | All the values for the non-zeros in the matrix will be ignored. 65 | If the input file contains only the graph structure, the value of b_getStructureOnly will be ignored 66 | */ 67 | int ReadMatrixMarketAdjacencyGraph(string s_InputFile, bool b_getStructureOnly = true); 68 | 69 | /// Write the structure of the graph into a file using Matrix Market format 70 | /** 71 | NOTES: 72 | - Because ColPack's internal graph does not have self loop, the output graph will not have any self-loops that exist in the input, 73 | i.e., diagonal entries of the input graph will be removed. 74 | */ 75 | int WriteMatrixMarket(string s_OutputFile = "-ColPack_debug.mtx", bool b_getStructureOnly = false); 76 | 77 | private: 78 | 79 | // ??? Wonder if this function is useful any more 80 | int ParseWidth(string FortranFormat); 81 | 82 | void CalculateVertexDegrees(); 83 | 84 | public: 85 | 86 | GraphInputOutput(); 87 | 88 | ~GraphInputOutput(); 89 | 90 | virtual void Clear(); 91 | 92 | string GetInputFile(); 93 | 94 | /// Read the entries of symmetric matrix in Harwell Boeing format and build the corresponding adjacency graph. 95 | /** 96 | Supported sub-format: MXTYPE[3] = (R | P) (S | U) (A) 97 | If MXTYPE[2] = 'U', the matrix structure must still be symmetric for ColPack to work correctly 98 | */ 99 | int ReadHarwellBoeingAdjacencyGraph(string s_InputFile); 100 | 101 | /// Read the entries of symmetric matrix in MeTiS format and build the corresponding adjacency graph. 102 | int ReadMeTiSAdjacencyGraph(string s_InputFile); 103 | 104 | // TO BE DOCUMENTED 105 | // ??? When do I need ReadMeTiSAdjacencyGraph2() instead of ReadMeTiSAdjacencyGraph() ? 106 | // probably need ReadMeTiSAdjacencyGraph2() when I need to read from a variant of MeTiS format 107 | int ReadMeTiSAdjacencyGraph2(string s_InputFile); 108 | 109 | int PrintGraph(); 110 | 111 | int PrintGraphStructure(); 112 | int PrintGraphStructure2(); 113 | 114 | int PrintMatrix(); 115 | 116 | int PrintMatrix(vector &, vector &, vector &); 117 | 118 | void PrintVertexDegrees(); 119 | }; 120 | } 121 | #endif 122 | 123 | -------------------------------------------------------------------------------- /src/GeneralGraphColoring/GraphOrdering.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | This file is part of ColPack, which is under its License protection. 3 | You should have received a copy of the License. If not, see 4 | 5 | *******************************************************************************/ 6 | 7 | #ifndef GRAPHORDERING_H 8 | #define GRAPHORDERING_H 9 | 10 | using namespace std; 11 | 12 | namespace ColPack 13 | { 14 | /** @ingroup group1 15 | * @brief class GraphOrdering in @link group1@endlink. 16 | 17 | This class stores the ordered vertices as a vector of vertex identifiers to be used by coloring methods. 18 | */ 19 | class GraphOrdering : public GraphInputOutput 20 | { 21 | public: 22 | ///Calculate and return the Maximum Back degree 23 | /** 24 | Precondition: OrderVertices() has been called, i.e. m_vi_OrderedVertices has been populated 25 | Note: Back degree of a vertex is the degree of that vertex 26 | in the subgraph consisting of vertices that had been ordered (i.e., the vertices that are ordered before the current vertex). 27 | Depend on the ordering style, each vertex in vector m_vi_OrderedVertices may have different Back degree. 28 | The Maximum Back degree of all vertices in the graph will be returned. 29 | This is the UPPER BOUND for the number of colors needed to D1-color the graph. 30 | //*/ 31 | int GetMaxBackDegree(); 32 | 33 | int OrderVertices(string s_OrderingVariant); 34 | 35 | /// Test and make sure that the ordering is valid. Return 0 if the ordering is invalid, 1 if the ordering is valid. 36 | /** This routine will test for: 37 | - Duplicated vertices. If there is no duplicated vertex, this ordering is probably ok. 38 | - Invalid vertex #. The vertex # should be between 0 and ordering.size() 39 | 40 | Actually make a call to "bool isValidOrdering(vector & ordering, int offset = 0);" 41 | */ 42 | int CheckVertexOrdering(); 43 | 44 | private: 45 | 46 | /// Get Back Degree of vertex m_vi_OrderedVertices[index] 47 | /** 48 | Precondition: OrderVertices() has been called, i.e. m_vi_OrderedVertices has been populated 49 | 50 | Note: This function is written quickly so it is not optimal 51 | //*/ 52 | int GetBackDegree(int index); 53 | 54 | //Private Function 1301 55 | int CheckVertexOrdering(string s_VertexOrderingVariant); 56 | 57 | int printVertexEdgeMap(vector< vector< pair< int, int> > > &vvpii_VertexEdgeMap); 58 | 59 | protected: 60 | 61 | double m_d_OrderingTime; 62 | 63 | string m_s_VertexOrderingVariant; 64 | 65 | vector m_vi_OrderedVertices; // m_vi_OrderedVertices.size() = m_vi_Vertices.size() - 1 66 | 67 | public: 68 | 69 | //Public Constructor 1351 70 | GraphOrdering(); 71 | 72 | //Public Destructor 1352 73 | ~GraphOrdering(); 74 | 75 | //Virtual Function 1353 76 | virtual void Clear(); 77 | void ClearOrderingONLY(); 78 | 79 | //Public Function 1354 80 | int NaturalOrdering(); 81 | 82 | int RandomOrdering(); 83 | 84 | int ColoringBasedOrdering(vector &vi_VertexColors); 85 | 86 | //Public Function 1355 87 | int LargestFirstOrdering(); 88 | 89 | //Public Function 1357 90 | int DistanceTwoLargestFirstOrdering(); 91 | 92 | //Public Function 1356 93 | int DynamicLargestFirstOrdering(); 94 | 95 | int DistanceTwoDynamicLargestFirstOrdering(); 96 | 97 | //Public Function 1358 98 | int SmallestLastOrdering(); 99 | int SmallestLastOrdering_serial(); 100 | 101 | //Public Function 1359 102 | int DistanceTwoSmallestLastOrdering(); 103 | 104 | //Public Function 1360 105 | int IncidenceDegreeOrdering(); 106 | 107 | //Public Function 1361 108 | int DistanceTwoIncidenceDegreeOrdering(); 109 | 110 | //Public Function 1362 111 | string GetVertexOrderingVariant(); 112 | 113 | //Public Function 1363 114 | void GetOrderedVertices(vector &output); 115 | vector * GetOrderedVerticesPtr(){ return &m_vi_OrderedVertices; } 116 | 117 | void PrintVertexOrdering(); 118 | 119 | //Public Function 1364 120 | double GetVertexOrderingTime(); 121 | }; 122 | } 123 | #endif 124 | 125 | 126 | -------------------------------------------------------------------------------- /src/Recovery/RecoveryCore.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | This file is part of ColPack, which is under its License protection. 3 | You should have received a copy of the License. If not, see 4 | 5 | *******************************************************************************/ 6 | 7 | #include "ColPackHeaders.h" 8 | 9 | using namespace std; 10 | 11 | namespace ColPack 12 | { 13 | RecoveryCore::RecoveryCore() { 14 | //formatType = "UNKNOWN"; 15 | 16 | //for ADOL-C Format (AF) 17 | AF_available = false; 18 | i_AF_rowCount = 0; 19 | dp2_AF_Value = NULL; 20 | 21 | //for Sparse Solvers Format (SSF) 22 | SSF_available = false; 23 | i_SSF_rowCount = 0; 24 | ip_SSF_RowIndex = NULL; 25 | ip_SSF_ColumnIndex = NULL; 26 | dp_SSF_Value = NULL; 27 | 28 | //for Coordinate Format (CF) 29 | CF_available = false; 30 | i_CF_rowCount = 0; 31 | ip_CF_RowIndex = NULL; 32 | ip_CF_ColumnIndex = NULL; 33 | dp_CF_Value = NULL; 34 | } 35 | 36 | void RecoveryCore::reset() { 37 | 38 | //for ADOL-C Format (AF) 39 | if (AF_available) { 40 | //free_2DMatrix(dp2_AF_Value, i_AF_rowCount); 41 | for( int i=0; i < i_AF_rowCount; i++ ) { 42 | free( dp2_AF_Value[i] ); 43 | } 44 | free( dp2_AF_Value ); 45 | 46 | dp2_AF_Value = NULL; 47 | AF_available = false; 48 | i_AF_rowCount = 0; 49 | } 50 | 51 | //for Sparse Solvers Format (SSF) 52 | if (SSF_available) { 53 | //delete[] ip_SSF_RowIndex; 54 | free(ip_SSF_RowIndex); 55 | ip_SSF_RowIndex = NULL; 56 | //delete[] ip_SSF_ColumnIndex; 57 | free(ip_SSF_ColumnIndex); 58 | ip_SSF_ColumnIndex = NULL; 59 | //delete[] dp_SSF_Value; 60 | free(dp_SSF_Value); 61 | dp_SSF_Value = NULL; 62 | SSF_available = false; 63 | i_SSF_rowCount = 0; 64 | } 65 | 66 | //for Coordinate Format (CF) 67 | if (CF_available) { 68 | //do something 69 | //delete[] ip_CF_RowIndex; 70 | free(ip_CF_RowIndex); 71 | ip_CF_RowIndex = NULL; 72 | //delete[] ip_CF_ColumnIndex; 73 | free(ip_CF_ColumnIndex); 74 | ip_CF_ColumnIndex = NULL; 75 | //delete[] dp_CF_Value; 76 | free(dp_CF_Value); 77 | dp_CF_Value = NULL; 78 | CF_available = false; 79 | i_CF_rowCount = 0; 80 | } 81 | 82 | //formatType = "UNKNOWN"; 83 | } 84 | 85 | RecoveryCore::~RecoveryCore() { 86 | 87 | //for ADOL-C Format (AF) 88 | if (AF_available) { 89 | //do something 90 | //free_2DMatrix(dp2_AF_Value, i_AF_rowCount); 91 | 92 | for( int i=0; i < i_AF_rowCount; i++ ) { 93 | free( dp2_AF_Value[i] ); 94 | } 95 | free( dp2_AF_Value ); 96 | } 97 | 98 | //for Sparse Solvers Format (SSF) 99 | if (SSF_available) { 100 | //do something 101 | //delete[] ip_SSF_RowIndex; 102 | free(ip_SSF_RowIndex); 103 | //delete[] ip_SSF_ColumnIndex; 104 | free(ip_SSF_ColumnIndex); 105 | //delete[] dp_SSF_Value; 106 | free(dp_SSF_Value); 107 | } 108 | 109 | //for Coordinate Format (CF) 110 | if (CF_available) { 111 | //do something 112 | //delete[] ip_CF_RowIndex; 113 | free(ip_CF_RowIndex); 114 | //delete[] ip_CF_ColumnIndex; 115 | free(ip_CF_ColumnIndex); 116 | //delete[] dp_CF_Value; 117 | free(dp_CF_Value); 118 | } 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /src/Recovery/RecoveryCore.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | This file is part of ColPack, which is under its License protection. 3 | You should have received a copy of the License. If not, see 4 | 5 | *******************************************************************************/ 6 | 7 | #ifndef RECOVERYCORE_H 8 | #define RECOVERYCORE_H 9 | 10 | using namespace std; 11 | 12 | namespace ColPack 13 | { 14 | /** @ingroup group5 15 | * @brief class RecoveryCore in @link group5@endlink. 16 | * 17 | * This class will keep track of all the memories allocated and 18 | * its destructor will be responsible to destroy the memory allocated for 19 | * arrays/matrices of all the Recovery classes. 20 | * 21 | * This class currently supports matrices in one of the following three formats: 22 | * RowCompressedFormat (AF), CoordinateFormat (CF), and SparseSolversFormat (SSF) 23 | * 24 | * For one graph, you can call the Recovery routine once for each format. 25 | * Calling the same recovery function twice will make this class reset() (see the example below): 26 | * 27 | * Matrix in a particular format is generated when the Recovery routine of the corresponding format is called. 28 | * For example, here is one possible sequence: 29 | * JacobianRecovery1D jr1d; // create an oject of subclass of RecoveryCore 30 | * jr1d.RecoverD2Row_RowCompressedFormat(graph1 , ...); // output matrix in ADOLC Format is generated 31 | * jr1d.RecoverD2Row_SparseSolversFormat(graph1 , ...); // output matrix in Sparse Solvers Format is generated 32 | * jr1d.RecoverD2Row_CoordinateFormat(graph1 , ...); // output matrix in Coordinate Format is generated 33 | * 34 | * // Matrices in all 3 formats will be deallocated, a new output matrix in Coordinate Format is generated 35 | * // Here, because the user call RecoverD2Row_CoordinateFormat() for the second time, 36 | * // we assume that the user have a new graph, so clean up old matrices is necessary. 37 | * // Note: DO NOT call the same recovery function twice unless you have a new graph!!! 38 | * jr1d.RecoverD2Row_CoordinateFormat(graph2 , ...); 39 | */ 40 | class RecoveryCore 41 | { 42 | public: // !!!NEED DOCUMENT 43 | RecoveryCore(); 44 | ~RecoveryCore(); 45 | protected: 46 | //string formatType; //At this point, could be either: "RowCompressedFormat," "CoordinateFormat," or "SparseSolversFormat" 47 | 48 | //for ADOL-C Format (AF) 49 | bool AF_available; 50 | int i_AF_rowCount; 51 | double** dp2_AF_Value; 52 | 53 | //for Sparse Solvers Format (SSF) 54 | bool SSF_available; 55 | int i_SSF_rowCount; 56 | unsigned int* ip_SSF_RowIndex; 57 | unsigned int* ip_SSF_ColumnIndex; 58 | double* dp_SSF_Value; 59 | 60 | //for Coordinate Format (CF) 61 | bool CF_available; 62 | int i_CF_rowCount; 63 | unsigned int* ip_CF_RowIndex; 64 | unsigned int* ip_CF_ColumnIndex; 65 | double* dp_CF_Value; 66 | 67 | void reset(); 68 | }; 69 | } 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /src/SMPGC/SMPGC.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | This file is part of ColPack, which is under its License protection. 3 | You should have received a copy of the License. If not, see 4 | 5 | *******************************************************************************/ 6 | 7 | #include "SMPGC.h" 8 | 9 | const std::string SMPGC::FORMAT_MM = "MM"; 10 | const std::string SMPGC::FORMAT_BINARY= "BINARY"; 11 | 12 | const int SMPGC::RAND_SEED ; 13 | const int SMPGC::HASH_SEED ; 14 | const int SMPGC::HASH_SHIFT ; 15 | const int SMPGC::HASH_NUM_HASH ; 16 | 17 | const int SMPGC::ORDER_NONE ; 18 | const int SMPGC::ORDER_NATURAL ; 19 | const int SMPGC::ORDER_RANDOM ; 20 | const int SMPGC::ORDER_LARGEST_FIRST; 21 | const int SMPGC::ORDER_SMALLEST_LAST; 22 | 23 | const int SMPGC::HYBRID_GM3P ; 24 | const int SMPGC::HYBRID_GMMP ; 25 | const int SMPGC::HYBRID_SERIAL ; 26 | const int SMPGC::HYBRID_STREAM ; 27 | 28 | -------------------------------------------------------------------------------- /src/SMPGC/SMPGC.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | This file is part of ColPack, which is under its License protection. 3 | You should have received a copy of the License. If not, see 4 | 5 | ******************************************************************************/ 6 | 7 | 8 | #ifndef SMPGCDEFINE_H 9 | #define SMPGCDEFINE_H 10 | #include 11 | // ============================================================================ 12 | // SMPGC: Shared Memory Parallel Graph Coloring 13 | // ---------------------------------------------------------------------------- 14 | // **OVERVIEW** 15 | // 16 | // SMPGCCore: Graph data, IO 17 | // |->SMPGCOrdering: Ordering 18 | // |-> SMPGCColoring: D1 Coloring 19 | // |-> D2SMPGCColoring: D2 Coloring 20 | // 21 | // ---------------------------------------------------------------------------- 22 | // **LIST OF ALGORITHMS** 23 | // * GM's Algorithm: Gebremedhin and Manne[1]. 24 | // * IP's Algorithm: Catalyurek Feo Gebremedhin and Halappanavar[2] 25 | // * JP's Algorithm: Jones and Plassmann[3] 26 | // * Luby's Alg 27 | // ... 28 | // ... 29 | // ---------------------------------------------------------------------------- 30 | // **LIST OF PAPERS** 31 | // [1] Scalable Parallel Graph Coloring Algorithms 32 | // [2] Grah coloring algorithms for multi-core and massively multithreaded architectures 33 | // [3] A Parallel Graph Coloring Heuristic 34 | // ... 35 | // ... 36 | // ============================================================================ 37 | 38 | class SMPGC{ 39 | //public: // in comman Computer is LP64 Model. change the following in case not. 40 | //typedef unsigned long long int uint64; 41 | //typedef long long int int64; 42 | //typedef unsigned int uint32; 43 | //typedef int int32; 44 | //#ifndef INT32 45 | // typedef uint64 UINT; 46 | // typedef int64 INT ; 47 | //#else 48 | // typedef uint32 UINT; 49 | // typedef int32 INT; 50 | //#endif 51 | 52 | public: 53 | static const int RAND_SEED = 5489u; 54 | 55 | static const int HASH_SEED = 5489u; 56 | static const int HASH_SHIFT = 0XC2A50F; 57 | static const int HASH_NUM_HASH = 4; 58 | 59 | static const std::string FORMAT_MM ; 60 | static const std::string FORMAT_BINARY; 61 | 62 | static const int ORDER_NONE = 0; 63 | static const int ORDER_NATURAL = 1; 64 | static const int ORDER_RANDOM = 2; 65 | static const int ORDER_LARGEST_FIRST = 3; 66 | static const int ORDER_SMALLEST_LAST = 4; 67 | 68 | static const int HYBRID_GM3P = 1; 69 | static const int HYBRID_GMMP = 2; 70 | static const int HYBRID_SERIAL = 3; 71 | static const int HYBRID_STREAM = 4; 72 | 73 | 74 | public: 75 | SMPGC(){}; 76 | ~SMPGC(){}; 77 | public: 78 | SMPGC(SMPGC&&)=delete; 79 | SMPGC(const SMPGC&)=delete; 80 | SMPGC& operator=(SMPGC&&)=delete; 81 | SMPGC& operator=(const SMPGC&)=delete; 82 | }; 83 | 84 | 85 | 86 | #endif 87 | 88 | 89 | -------------------------------------------------------------------------------- /src/SMPGC/SMPGCColoring.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | This file is part of ColPack, which is under its License protection. 3 | You should have received a copy of the License. If not, see 4 | 5 | *******************************************************************************/ 6 | #ifndef SMPGCColoring_H 7 | #define SMPGCColoring_H 8 | #include 9 | #include 10 | #include "ColPackHeaders.h" //#include "GraphOrdering.h" 11 | #include "SMPGCOrdering.h" 12 | 13 | using namespace std; 14 | 15 | namespace ColPack { 16 | 17 | //============================================================================= 18 | // Shared Memeory Parallel (Greedy)/Graph Coloring -> SMPGC 19 | // ---------------------------------------------------------------------------- 20 | // 21 | // SMPGC includes three main algorithms 22 | // * GM's Algorithm: Gebremedhin and Manne[1]. 23 | // * IP's Algorithm: Catalyurek Feo Gebremedhin and Halappanavar[2] 24 | // * JP's Algorithm: Jones and Plassmann[3] 25 | // * Luby's Alg 26 | // * JP-LF 27 | // * JP_SL 28 | // ---------------------------------------------------------------------------- 29 | // [1] Scalable Parallel Graph Coloring Algorithms 30 | // [2] Grah coloring algorithms for multi-core and massively multithreaded architectures 31 | // [3] A Parallel Graph Coloring Heuristic 32 | //============================================================================= 33 | 34 | 35 | // ============================================================================ 36 | // Shared Memeory Parallel Greedy/Graph Coloring 37 | // ============================================================================ 38 | class SMPGCColoring : public SMPGCOrdering { 39 | public: // Constructions 40 | SMPGCColoring(const string& graph_name); 41 | SMPGCColoring(const string& graph_name, const string& fmt, double*iotime=nullptr, const string&ord="NATURAL", double*ordtime=nullptr); 42 | virtual ~SMPGCColoring(){} 43 | 44 | // Deplete constructions 45 | SMPGCColoring(SMPGCColoring&&)=delete; 46 | SMPGCColoring(const SMPGCColoring&)=delete; 47 | SMPGCColoring& operator=(SMPGCColoring&&)=delete; 48 | SMPGCColoring& operator=(const SMPGCColoring&)=delete; 49 | 50 | public: // API 51 | int Coloring(int nT, const string& method, const int switch_iter); 52 | 53 | int get_num_colors(){ return m_total_num_colors; } 54 | const vector& get_vertex_colors() const { return m_vertex_color; } 55 | void get_vertex_colors(vector& x) { x.assign(m_vertex_color.begin(), m_vertex_color.end()); } 56 | 57 | // original algorithms 58 | int D1_OMP_GM3P_orig(int nT, int&color, vector&vtxColors); 59 | int D1_OMP_GMMP_orig(int nT, int&color, vector&vtxColors); 60 | 61 | // Algorithms 62 | int D1_serial(int &color, vector&vtxColors, const int local_order); 63 | 64 | int D1_OMP_GM3P(int nT, int&color, vector&vtxColors, const int local_order=ORDER_NONE); 65 | int D1_OMP_GMMP(int nT, int&color, vector&vtxColors, const int local_order=ORDER_NONE); 66 | int D1_OMP_LB (int nT, int&color, vector&vtxColors, const int local_order=ORDER_NONE); 67 | int D1_OMP_JP (int nT, int&color, vector&vtxColors, const int local_order=ORDER_NONE); 68 | int D1_OMP_MTJP(int nT, int&color, vector&vtxColors, const int local_order=ORDER_NONE); 69 | int D1_OMP_HBJP (int nT, int&color, vector&vtxColors, const int option=HYBRID_SERIAL, const int swtich_iter=0, const int local_order=ORDER_NONE); 70 | int D1_OMP_HBMTJP(int nT, int&color, vector&vtxColors, const int option=HYBRID_SERIAL, const int switch_iter=0, const int local_order=ORDER_NONE); 71 | 72 | int D1_OMP_GM3P_BIT(int nT, int&color, vector&vtxColors, const int local_order=ORDER_NONE); 73 | int D1_OMP_GMMP_BIT(int nT, int&color, vector&vtxColors, const int local_order=ORDER_NONE); 74 | 75 | 76 | 77 | // Algorithm for distance two coloring 78 | int D2_serial(int &color, vector&vtxColors, const int local_order=ORDER_NONE); 79 | 80 | int D2_OMP_GM3P (int nT, int&color, vector&vtxColors, const int local_order=ORDER_NONE); 81 | int D2_OMP_GMMP (int nT, int&color, vector&vtxColors, const int local_order=ORDER_NONE); 82 | 83 | // inner Algorithm for Hybird 84 | inline void hybrid_GM3P(const int nT, vector&vtxColors, vector>&Q, const int local_order=ORDER_NONE); 85 | inline void hybrid_GMMP(const int nT, vector&vtxColors, vector>&Q, const int local_order=ORDER_NONE); 86 | inline void hybrid_Serial(vector&vtxColors, vector>&Q, const int local_order=ORDER_NONE); 87 | 88 | 89 | public: // Utilites 90 | int cnt_d1conflict(const vector& vc, bool bVerbose=false); 91 | int cnt_d2conflict(const vector& vc, bool bVerbose=false); 92 | 93 | private: 94 | 95 | unsigned int mhash(unsigned int a, unsigned int seed){ 96 | a ^= seed; 97 | a = (a + 0x7ed55d16) + (a << 12); 98 | a = (a ^ 0xc761c23c) + (a >> 19); 99 | a = (a + 0x165667b1) + (a << 5); 100 | a = (a ^ 0xd3a2646c) + (a << 9); 101 | a = (a + 0xfd7046c5) + (a << 3); 102 | a = (a ^ 0xb55a4f09) + (a >> 16); 103 | return a; 104 | } 105 | 106 | 107 | 108 | 109 | protected: 110 | int m_total_num_colors; 111 | vector m_vertex_color; 112 | string m_method; 113 | 114 | }; // end of class SMPGCColoring 115 | 116 | 117 | }// endof namespace ColPack 118 | #endif 119 | 120 | -------------------------------------------------------------------------------- /src/SMPGC/SMPGCGraph.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | This file is part of ColPack, which is under its License protection. 3 | You should have received a copy of the License. If not, see 4 | 5 | *******************************************************************************/ 6 | #ifndef SMPGCGRAPH_H 7 | #define SMPGCGRAPH_H 8 | #include "SMPGC.h" 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include "ColPackHeaders.h" //#include "GraphOrdering.h" 14 | 15 | using namespace std; 16 | 17 | namespace ColPack { 18 | // ============================================================================ 19 | // Shared Memory Parallel Graph Coloring Core 20 | // ---------------------------------------------------------------------------- 21 | // the graphs are stored uisng using CSR format. 22 | // a, ia, ja. are names inherited from Intel MKL Api 23 | // usually known as non-zero-values, col-pointers, col-values 24 | // ============================================================================ 25 | class SMPGCGraph: public SMPGC{ 26 | public: // Constructions 27 | SMPGCGraph(); 28 | SMPGCGraph(const string& fname, const string& format, double*iotime); 29 | virtual ~SMPGCGraph(); 30 | public: // Constructions 31 | SMPGCGraph(SMPGCGraph&&)=delete; 32 | SMPGCGraph(const SMPGCGraph&)=delete; 33 | SMPGCGraph& operator=(SMPGCGraph&&)=delete; 34 | SMPGCGraph& operator=(const SMPGCGraph&)=delete; 35 | 36 | public: // APIs 37 | int num_nodes() const { return m_ia.empty()?0:(m_ia.size()-1); } 38 | double avg_degree() const { return m_avg_degree; } 39 | int max_degree() const { return m_max_degree; } 40 | int min_degree() const { return m_min_degree; } 41 | 42 | const vector& get_CSR_ia() const { return m_ia; } 43 | const vector& get_CSR_ja() const { return m_ja; } 44 | const vector& get_CSR_a () const { return m_a; } 45 | 46 | 47 | protected: // implements 48 | virtual void do_read_Metis_struct(const string &fname, vector&vi, vector&vj, int*p_maxdeg, int*p_mindeg, double *p_avgdeg, double*iotime); 49 | virtual void do_read_MM_struct(const string& fname, vector&vi, vector&vj, int*p_maxdeg, int*p_mindeg, double *p_avgdeg, double*iotime); 50 | //virtual void do_read_Binary_struct(const string& fname, vector&vi, vector&vj, int *p_maxdeg, int*p_mindeg, double*p_avgdeg, double*iotime); 51 | //virtual void do_write_Binary_struct(const string& fname, vector&vi, vector&vj, double*iotime); 52 | 53 | protected: 54 | // CSR format, using Intel MKL naming 55 | vector m_ia; //known as verPtr; size: graph size + 1 56 | vector m_ja; //known as verVal; size: nnz 57 | vector m_a; //known as nzval; size: nnz 58 | 59 | int m_max_degree; 60 | int m_min_degree; 61 | double m_avg_degree; 62 | 63 | string m_graph_name; 64 | }; 65 | 66 | } 67 | #endif 68 | 69 | -------------------------------------------------------------------------------- /src/SMPGC/SMPGCOrdering.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | This file is part of ColPack, which is under its License protection. 3 | You should have received a copy of the License. If not, see 4 | 5 | *******************************************************************************/ 6 | #ifndef SMPGCORDERING_H 7 | #define SMPGCORDERING_H 8 | #include 9 | #include 10 | #include 11 | #include "ColPackHeaders.h" //#include "GraphOrdering.h" 12 | #include "SMPGCGraph.h" 13 | #include 14 | #include 15 | 16 | using namespace std; 17 | 18 | namespace ColPack { 19 | 20 | //============================================================================= 21 | // Shared Memeory Parallel (Greedy)/Graph Coloring -> SMPGC 22 | // ---------------------------------------------------------------------------- 23 | // 24 | // SMPGC includes three main algorithms 25 | // * GM's Algorithm: Gebremedhin and Manne[1]. 26 | // * IP's Algorithm: Catalyurek Feo Gebremedhin and Halappanavar[2] 27 | // * JP's Algorithm: Jones and Plassmann[3] 28 | // * Luby's Alg 29 | // * JP-LF 30 | // * JP_SL 31 | // ---------------------------------------------------------------------------- 32 | // [1] Scalable Parallel Graph Coloring Algorithms 33 | // [2] Grah coloring algorithms for multi-core and massively multithreaded architectures 34 | // [3] A Parallel Graph Coloring Heuristic 35 | //============================================================================= 36 | 37 | 38 | 39 | 40 | // ============================================================================ 41 | // Shared Memory Parallel Greedy/Graph Coloring Ordering wrap 42 | // ============================================================================ 43 | class SMPGCOrdering : public SMPGCGraph { 44 | public: // construction 45 | SMPGCOrdering(const string& file_name, const string& fmt, double*iotime, const string& order, double *ordtime); 46 | virtual ~SMPGCOrdering(); 47 | 48 | public: // deplete construction 49 | SMPGCOrdering(SMPGCOrdering&&)=delete; 50 | SMPGCOrdering(const SMPGCOrdering&)=delete; 51 | SMPGCOrdering& operator=(SMPGCOrdering&&)=delete; 52 | SMPGCOrdering& operator=(const SMPGCOrdering&)=delete; 53 | 54 | public: // API: global ordering 55 | void global_ordering(const string& order, double*t); 56 | const vector& global_ordered_vertex() const { return m_global_ordered_vertex; } 57 | const string& global_ordered_method() const { return m_global_ordered_method; } 58 | void set_rseed(const int x){ m_mt.seed(x); } 59 | 60 | protected: 61 | void global_natural_ordering(); 62 | void global_random_ordering(); 63 | void global_largest_degree_first_ordering(); 64 | 65 | protected: // API: local ordering 66 | void local_natural_ordering(vector& vtxs); 67 | void local_random_ordering (vector& vtxs); 68 | void local_largest_degree_first_ordering(vector& vtxs); 69 | void local_largest_degree_first_ordering(vector& vtxs, const int beg, const int end); 70 | void local_smallest_degree_last_ordering(vector& vtxs); 71 | void local_smallest_degree_last_ordering_B1a(vector& vtxs); 72 | 73 | //void SmallestDegreeLastOrdering(vector& vtxs, INT N); 74 | //void DynamicLargestDegreeFirstOrdering(vector& vtxs, INT N); 75 | //void IncidenceDegreeOrdering(vector& vtxs, INT N); 76 | //void LogOrdering(vector& vtxs, INT N); 77 | 78 | protected: // members 79 | vector m_global_ordered_vertex; 80 | string m_global_ordered_method; 81 | mt19937 m_mt; 82 | }; 83 | 84 | 85 | 86 | 87 | }// endof namespace ColPack 88 | #endif 89 | 90 | -------------------------------------------------------------------------------- /src/Utilities/CoutLock.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | This file is part of ColPack, which is under its License protection. 3 | You should have received a copy of the License. If not, see 4 | 5 | *******************************************************************************/ 6 | 7 | #include "Definitions.h" 8 | 9 | #include "CoutLock.h" 10 | 11 | namespace ColPack 12 | { 13 | #ifdef _OPENMP 14 | omp_lock_t CoutLock::coutLock; 15 | #endif 16 | 17 | int CoutLock::unset() 18 | { 19 | #ifdef _OPENMP 20 | omp_unset_lock(&CoutLock::coutLock); 21 | #endif 22 | return 0; 23 | } 24 | int CoutLock::set() 25 | { 26 | #ifdef _OPENMP 27 | omp_set_lock(&CoutLock::coutLock); 28 | #endif 29 | return 0; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Utilities/CoutLock.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | This file is part of ColPack, which is under its License protection. 3 | You should have received a copy of the License. If not, see 4 | 5 | *******************************************************************************/ 6 | 7 | #ifndef COUTLOCK_H 8 | #define COUTLOCK_H 9 | 10 | #ifdef _OPENMP 11 | #include 12 | #endif 13 | 14 | namespace ColPack 15 | { 16 | /** @ingroup group4 17 | * @brief class CoutLock in @link group4@endlink. 18 | 19 | The CoutLock class is used in a multi-thread environment to support printing strings to standard output in a readable manner. 20 | Here is how you do cout: 21 | CoutLock::set(); cout<<"blah blah blah"< 5 | *******************************************************************************/ 6 | 7 | #include 8 | #include 9 | 10 | using namespace std; 11 | 12 | #include "Definitions.h" 13 | 14 | #include "DisjointSets.h" 15 | 16 | namespace ColPack 17 | { 18 | //Public Constructor 4251 19 | DisjointSets::DisjointSets() 20 | { 21 | 22 | } 23 | 24 | 25 | //Public Constructor 4252 26 | DisjointSets::DisjointSets(int li_SetSize) 27 | { 28 | p_vi_Nodes.clear(); 29 | p_vi_Nodes.resize((unsigned) li_SetSize, _UNKNOWN); 30 | } 31 | 32 | 33 | //Public Destructor 4253 34 | DisjointSets::~DisjointSets() 35 | { 36 | p_vi_Nodes.clear(); 37 | } 38 | 39 | 40 | //Public Function 4254 41 | int DisjointSets::SetSize(int li_SetSize) 42 | { 43 | p_vi_Nodes.clear(); 44 | p_vi_Nodes.resize((unsigned) li_SetSize, _UNKNOWN); 45 | 46 | return(_TRUE); 47 | } 48 | 49 | 50 | //Public Function 4255 51 | int DisjointSets::Count() 52 | { 53 | int i; 54 | 55 | int li_SetSize, li_HeadCount; 56 | 57 | li_SetSize = (signed) p_vi_Nodes.size(); 58 | 59 | li_HeadCount = _FALSE; 60 | 61 | for(i=0; i 5 | *******************************************************************************/ 6 | 7 | #ifndef DISJOINTSETS_H 8 | #define DISJOINTSETS_H 9 | 10 | using namespace std; 11 | 12 | namespace ColPack 13 | { 14 | /** @ingroup group4 15 | * @brief class DisjointSets in @link group4@endlink. 16 | 17 | The disjoint set class is used by ColPack to store and operate on disjoint sets of edges identified by 18 | integer numbers. A disjoint set class can be instantiated by specifying the maximum number of such sets to 19 | be stored. The elements in a set are stored as a tree and the identifier of the set (SetID) is the identifier of the root. 20 | The size of the tree is stored in the root and the parent of an element is stored in the element. The tree is 21 | implemented simply as a vector of integers the indices being the identifiers of the elements. 22 | */ 23 | class DisjointSets 24 | { 25 | private: 26 | 27 | vector p_vi_Nodes; 28 | 29 | public: 30 | 31 | //Public Constructor 4251 32 | DisjointSets(); 33 | 34 | //Public Constructor 4252 35 | DisjointSets(int); 36 | 37 | //Public Destructor 4253 38 | ~DisjointSets(); 39 | 40 | //Public Function 4254 41 | /// Set the size of this DisjointSets object, i.e. resize the vector p_vi_Nodes 42 | int SetSize(int); 43 | 44 | //Public Function 4255 45 | /// Count the number of sets contained by this DisjointSets object 46 | int Count(); 47 | 48 | //Public Function 4256 49 | /// Print out the elements' ID and their values (i.e., p_vi_Nodes's IDs and values) 50 | int Print(); 51 | 52 | //Public Function 4257 53 | /// Find the Set ID of this element 54 | int Find(int); 55 | 56 | //Public Function 4258 57 | /// Find the Set ID of this element, also shorten the tree by updating all elements with its new SetID 58 | int FindAndCompress(int); 59 | 60 | //Public Function 4259 61 | /// Union li_SetOne with li_SetTwo by seting li_SetOne to be the parent of li_SetTwo 62 | /** 63 | Return the SetID of the new set. In this case, SetID will be li_SetOne 64 | */ 65 | int Union(int li_SetOne, int li_SetTwo); 66 | 67 | //Public Function 4260 68 | /// Union li_SetOne with li_SetTwo by their ranks 69 | /** 70 | Rank: the upper bound on the height of the tree (or set) 71 | The root of each set will hold its the negate of its set rank 72 | i.e. rank of set 2 is (-p_vi_Nodes[2]) 73 | 74 | Note: UnionByRank() and UnionBySize() can not be used together to solve the same 75 | problem due to the different meaning of the root's value 76 | */ 77 | int UnionByRank(int li_SetOne, int li_SetTwo); 78 | 79 | //Public Function 4261 80 | /// Union li_SetOne with li_SetTwo by their sizes 81 | /** 82 | The root of each set will hold its the negate of its set size 83 | i.e. size of set 2 is (-p_vi_Nodes[2]) 84 | 85 | Note: UnionByRank() and UnionBySize() can not be used together to solve the same 86 | problem due to the different meaning of the root's value 87 | */ 88 | int UnionBySize(int li_SetOne, int li_SetTwo); 89 | 90 | }; 91 | } 92 | #endif 93 | -------------------------------------------------------------------------------- /src/Utilities/File.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | This file is part of ColPack, which is under its License protection. 3 | You should have received a copy of the License. If not, see 4 | 5 | *******************************************************************************/ 6 | 7 | #include 8 | 9 | #include "Definitions.h" 10 | 11 | #include "File.h" 12 | 13 | using namespace std; 14 | 15 | namespace ColPack 16 | { 17 | File::File() 18 | { 19 | path = ""; 20 | name = ""; 21 | fileExtension = ""; 22 | } 23 | 24 | File::File(string fileName) 25 | { 26 | path = ""; 27 | name = ""; 28 | fileExtension = ""; 29 | Parse(fileName); 30 | } 31 | 32 | string File::GetPath() const {return path;} 33 | 34 | string File::GetName() const {return name;} 35 | 36 | string File::GetFileExtension() const {return fileExtension;} 37 | 38 | string File::GetFullName() const {return name+"."+fileExtension;} 39 | 40 | void File::SetPath(string newPath) {path = newPath;} 41 | 42 | void File::SetName(string newName) {name = newName;} 43 | 44 | void File::SetFileExtension(string newFileExtension) {fileExtension = newFileExtension;} 45 | 46 | void File::Parse(string fileName) { 47 | string::size_type result; 48 | 49 | //1. see if the fileName is given in full path 50 | result = fileName.rfind(DIR_SEPARATOR, fileName.size() - 1); 51 | if(result != string::npos) {//found the path (file prefix) 52 | //get the path, including the last DIR_SEPARATOR 53 | path = fileName.substr(0,result+1); 54 | //remove the path from the fileName 55 | fileName = fileName.substr(result+1); 56 | } 57 | 58 | //2. see if the fileName has file extension. For example ".mtx" 59 | result = fileName.rfind('.', fileName.size() - 1); 60 | if(result != string::npos) {//found the fileExtension 61 | //get the fileExtension excluding the '.' 62 | fileExtension = fileName.substr(result+1); 63 | //remove the fileExtension from the fileName 64 | fileName = fileName.substr(0,result); 65 | } 66 | 67 | //3. get the name of the input file 68 | name = fileName; 69 | } 70 | 71 | bool isMatrixMarketFormat(string s_fileExtension) { 72 | if (s_fileExtension == "mtx") 73 | return true; 74 | return false; 75 | } 76 | 77 | bool isHarwellBoeingFormat(string s_fileExtension){ 78 | if (s_fileExtension == "hb" || ( 79 | s_fileExtension.size()==3 && ( 80 | // First Character of the Extension 81 | s_fileExtension[0] == 'r' || // Real matrix 82 | s_fileExtension[0] == 'c' || // Complex matrix 83 | s_fileExtension[0] == 'p' // Pattern only (no numerical values supplied) 84 | ) && ( 85 | // Second Character of the Extension 86 | s_fileExtension[1] == 's' || // Symmetric 87 | s_fileExtension[1] == 'u' || // Unsymmetric 88 | s_fileExtension[1] == 'h' || // Hermitian 89 | s_fileExtension[1] == 'g' || // Skew symmetric 90 | s_fileExtension[1] == 'r' // Rectangular 91 | ) && ( 92 | // Third Character of the Extension 93 | s_fileExtension[2] == 'a' || // Assembled 94 | s_fileExtension[2] == 'e' // Elemental matrices (unassembled) 95 | )) 96 | ) 97 | return true; 98 | return false; 99 | } 100 | 101 | bool isMeTiSFormat(string s_fileExtension){ 102 | if (s_fileExtension == "graph") 103 | return true; 104 | return false; 105 | } 106 | 107 | } 108 | -------------------------------------------------------------------------------- /src/Utilities/File.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | This file is part of ColPack, which is under its License protection. 3 | You should have received a copy of the License. If not, see 4 | 5 | *******************************************************************************/ 6 | 7 | #ifndef FILE_H 8 | #define FILE_H 9 | 10 | #include 11 | 12 | using namespace std; 13 | 14 | //#undef _WIN32 15 | 16 | //define system-dependent directory separator 17 | #ifdef _WIN32 //Windows 18 | #define DIR_SEPARATOR "\\" 19 | #else //*nix 20 | #define DIR_SEPARATOR "/" 21 | #endif 22 | 23 | 24 | namespace ColPack 25 | { 26 | /** @ingroup group4 27 | * @brief class File in @link group4@endlink. 28 | 29 | The File class is used to process file name. It should work on both Windows and *nix. A File object will 30 | take a file name, parse and separate it into 3 parts: path (name prefix), name, and file extension. 31 | */ 32 | class File 33 | { 34 | private: 35 | 36 | string path; //including the last DIR_SEPARATOR 37 | string name; 38 | string fileExtension; //excluding the '.' 39 | 40 | public: 41 | 42 | File(); 43 | 44 | File(string fileName); 45 | 46 | void Parse(string newFileName); 47 | 48 | string GetPath() const; 49 | 50 | string GetName() const; 51 | 52 | ///GetFileExtension excluding the '.' 53 | string GetFileExtension() const; 54 | 55 | string GetFullName() const; 56 | 57 | void SetPath(string newPath); 58 | 59 | void SetName(string newName); 60 | 61 | void SetFileExtension(string newFileExtension); 62 | 63 | }; 64 | 65 | ///Tell whether or not the file format is MatrixMarket from its extension 66 | bool isMatrixMarketFormat(string s_fileExtension); 67 | 68 | ///Tell whether or not the file format is HarwellBoeing from its extension 69 | bool isHarwellBoeingFormat(string s_fileExtension); 70 | 71 | ///Tell whether or not the file format is MeTiS from its extension 72 | bool isMeTiSFormat(string s_fileExtension); 73 | } 74 | #endif 75 | -------------------------------------------------------------------------------- /src/Utilities/MatrixDeallocation.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | This file is part of ColPack, which is under its License protection. 3 | You should have received a copy of the License. If not, see 4 | 5 | *******************************************************************************/ 6 | 7 | #include "MatrixDeallocation.h" 8 | 9 | int MatrixDeallocation_SparseSolversFormat(unsigned int **ip2_RowIndex, unsigned int **ip2_ColumnIndex, double **dp2_JacobianValue) { 10 | //Deallocate the arrays 11 | delete[] (*ip2_RowIndex); 12 | delete ip2_RowIndex; 13 | 14 | delete[] (*ip2_ColumnIndex); 15 | delete ip2_ColumnIndex; 16 | 17 | delete[] (*dp2_JacobianValue); 18 | delete dp2_JacobianValue; 19 | 20 | return _TRUE; 21 | } 22 | 23 | int MatrixDeallocation_RowCompressedFormat(double ***dp3_HessianValue, unsigned int i_numOfRows) { 24 | //Deallocate the 2D Matrix 25 | free_2DMatrix(dp3_HessianValue, i_numOfRows); 26 | return _TRUE; 27 | } 28 | 29 | 30 | int MatrixDeallocation_CoordinateFormat(unsigned int **ip2_RowIndex, unsigned int **ip2_ColumnIndex, double **dp2_HessianValue) { 31 | //Deallocate the arrays 32 | delete[] (*ip2_RowIndex); 33 | delete ip2_RowIndex; 34 | 35 | delete[] (*ip2_ColumnIndex); 36 | delete ip2_ColumnIndex; 37 | 38 | delete[] (*dp2_HessianValue); 39 | delete dp2_HessianValue; 40 | 41 | return _TRUE; 42 | } 43 | 44 | -------------------------------------------------------------------------------- /src/Utilities/MatrixDeallocation.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | This file is part of ColPack, which is under its License protection. 3 | You should have received a copy of the License. If not, see 4 | 5 | *******************************************************************************/ 6 | 7 | #include "Definitions.h" 8 | 9 | #ifndef MATRIXDEALLOCATION_H 10 | #define MATRIXDEALLOCATION_H 11 | 12 | /// Deallocate all the memory reserved for a matrix presented in Sparse Solvers Format 13 | /** Postcondition: 14 | - ip2_RowIndex, ip2_ColumnIndex, dp2_JacobianValue become dangling pointers. So for safety reasons, please set ip2_RowIndex, ip2_ColumnIndex, dp2_JacobianValue to NULL after calling this function. 15 | */ 16 | int MatrixDeallocation_SparseSolversFormat(unsigned int **ip2_RowIndex, unsigned int **ip2_ColumnIndex, double **dp2_JacobianValue); 17 | 18 | /// Deallocate all the memory reserved for a matrix presented in ADOLC Format 19 | /** Postcondition: 20 | - dp3_HessianValue become dangling pointers. So for safety reasons, please set dp3_HessianValue to NULL after calling this function. 21 | */ 22 | int MatrixDeallocation_RowCompressedFormat(double ***dp3_HessianValue, unsigned int i_numOfRows); 23 | 24 | /** Deallocate all the memory reserved for a matrix presented in Coordinate Format 25 | Postcondition: 26 | - ip2_RowIndex, ip2_ColumnIndex, dp2_HessianValue become dangling pointers. So for safety reasons, please set ip2_RowIndex, ip2_ColumnIndex, dp2_HessianValue to NULL after calling this function. 27 | */ 28 | int MatrixDeallocation_CoordinateFormat(unsigned int **ip2_RowIndex, unsigned int **ip2_ColumnIndex, double **dp2_HessianValue); 29 | 30 | 31 | template 32 | int free_2DMatrix(T **dp2_2DMatrix, unsigned int i_numOfRows) { 33 | for(unsigned int i=0; i< i_numOfRows; i++) { 34 | delete[] (dp2_2DMatrix)[i]; 35 | } 36 | delete[] (dp2_2DMatrix); 37 | 38 | return _TRUE; 39 | } 40 | 41 | template 42 | int free_2DMatrix(T ***dp3_2DMatrix, unsigned int i_numOfRows) { 43 | free_2DMatrix(*dp3_2DMatrix,i_numOfRows); 44 | delete dp3_2DMatrix; 45 | 46 | return _TRUE; 47 | } 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /src/Utilities/Pause.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | This file is part of ColPack, which is under its License protection. 3 | You should have received a copy of the License. If not, see 4 | 5 | *******************************************************************************/ 6 | 7 | //Special pause that work on both Windows and UNIX for both C and C++ 8 | #include "Pause.h" 9 | 10 | using namespace std; 11 | 12 | void Pause() 13 | { 14 | printf("Press enter to continue ..."); 15 | getchar(); 16 | } 17 | -------------------------------------------------------------------------------- /src/Utilities/Pause.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | This file is part of ColPack, which is under its License protection. 3 | You should have received a copy of the License. If not, see 4 | 5 | *******************************************************************************/ 6 | 7 | #include 8 | #include 9 | 10 | //Special pause that work on both Windows and UNIX for both C and C++ 11 | void Pause(); 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/Utilities/StringTokenizer.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | This file is part of ColPack, which is under its License protection. 3 | You should have received a copy of the License. If not, see 4 | 5 | *******************************************************************************/ 6 | 7 | #ifndef STRINGTOKENIZER_H 8 | #define STRINGTOKENIZER_H 9 | 10 | using namespace std; 11 | 12 | namespace ColPack 13 | { 14 | /** @ingroup group4 15 | * @brief class StringTokenizer in @link group4@endlink. 16 | 17 | The string tokenizer class is provided as an utility class to assist in reading various matrix and graph 18 | format files. As an input file is read line by line as strings, this class is used to tokenize the lines with one 19 | or more tokenizing strings which are generally the separators used in the input file. The string tokens are 20 | then restored to the intended data format without losing the actual precision of the original data. A string 21 | tokenizer class can be instantiated with an input string and an input tokenizer string or character array. 22 | */ 23 | class StringTokenizer 24 | { 25 | private: 26 | 27 | string DelimiterString; 28 | string InputString; 29 | string TokenString; 30 | 31 | public: 32 | 33 | //Public Constructor 4151 34 | StringTokenizer(); 35 | 36 | //Public Constructor 4152 37 | StringTokenizer(char *); 38 | 39 | //Public Constructor 4153 40 | StringTokenizer(char *, char *); 41 | 42 | //Public Constructor 4154 43 | StringTokenizer(string, char *); 44 | 45 | //Public Constructor 4155 46 | StringTokenizer(string, string); 47 | 48 | //Public Destructor 4156 49 | ~StringTokenizer(); 50 | 51 | //Public Function 4157 52 | int CountTokens(); 53 | 54 | //Public Function 4158 55 | int CountTokens(char *); 56 | 57 | //Public Function 4159 58 | string GetDelimiterString() const; 59 | 60 | //Public Function 4160 61 | string GetFirstToken(); 62 | 63 | //Public Function 4161 64 | string GetInputString() const; 65 | 66 | //Public Function 4162 67 | string GetLastToken(); 68 | 69 | //Public Function 4163 70 | string GetNextToken(); 71 | 72 | //Public Function 4164 73 | string GetNextToken(char *); 74 | 75 | //Public Function 4165 76 | string GetToken(int); 77 | 78 | //Public Function 4166 79 | int HasMoreTokens(); 80 | 81 | //Public Function 4167 82 | int HasMoreTokens(char *); 83 | 84 | //Public Function 4168 85 | int SetInputString(char *); 86 | 87 | //Public Function 4169 88 | int SetDelimiterString(char *); 89 | 90 | }; 91 | } 92 | #endif 93 | -------------------------------------------------------------------------------- /src/Utilities/Timer.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | This file is part of ColPack, which is under its License protection. 3 | You should have received a copy of the License. If not, see 4 | 5 | *******************************************************************************/ 6 | 7 | //using namespace std; 8 | 9 | #include "Definitions.h" 10 | 11 | #include "Timer.h" 12 | 13 | namespace ColPack 14 | { 15 | //Public Constructor 4351 16 | Timer::Timer() 17 | { 18 | 19 | } 20 | 21 | 22 | //Public Destructor 4352 23 | Timer::~Timer() 24 | { 25 | 26 | } 27 | 28 | 29 | //Public Function 4354 30 | void Timer::Start() 31 | { 32 | 33 | #ifdef SYSTEM_TIME 34 | 35 | ct_BeginTimer = times(&tms_BeginTimer); 36 | 37 | #else 38 | 39 | ct_BeginTimer = clock(); 40 | 41 | #endif 42 | 43 | } 44 | 45 | //Public Function 4355 46 | void Timer::Stop() 47 | { 48 | 49 | #ifdef SYSTEM_TIME 50 | 51 | ct_EndTimer = times(&tms_EndTimer); 52 | 53 | #else 54 | 55 | ct_EndTimer = clock(); 56 | 57 | #endif 58 | 59 | } 60 | 61 | //Public Function 4356 62 | double Timer::GetWallTime() 63 | { 64 | 65 | #ifdef SYSTEM_TIME 66 | 67 | return (double)(ct_EndTimer - ct_BeginTimer) / CLK_TCK; 68 | 69 | #else 70 | 71 | return (double)(ct_EndTimer - ct_BeginTimer) / CLOCKS_PER_SEC; 72 | 73 | #endif 74 | 75 | } 76 | 77 | //Public Function 4357 78 | double Timer::GetProcessorTime() 79 | { 80 | 81 | #ifdef SYSTEM_TIME 82 | 83 | double t_UserTime = (double) (tms_EndTimer.tms_utime - tms_BeginTimer.tms_utime) / CLK_TCK; 84 | double t_SystemTime = (double) (tms_EndTimer.tms_stime - tms_BeginTimer.tms_stime) / CLK_TCK; 85 | 86 | return(t_UserTime + t_SystemTime); 87 | 88 | #else 89 | 90 | return(_UNKNOWN); 91 | 92 | #endif 93 | 94 | } 95 | 96 | //Public Function 4358 97 | double Timer::GetUserProcessorTime() 98 | { 99 | 100 | #ifdef SYSTEM_TIME 101 | 102 | double t_UserTime = (double)(tms_EndTimer.tms_utime - tms_BeginTimer.tms_utime) / CLK_TCK; 103 | 104 | return(t_UserTime); 105 | 106 | #else 107 | 108 | return(_UNKNOWN); 109 | 110 | #endif 111 | 112 | } 113 | 114 | //Public Function 4359 115 | double Timer::GetSystemProcessorTime() 116 | { 117 | 118 | #ifdef SYSTEM_TIME 119 | 120 | double t_SystemTime = (double)(tms_EndTimer.tms_stime - tms_BeginTimer.tms_stime) / CLK_TCK; 121 | 122 | return(t_SystemTime); 123 | 124 | #else 125 | 126 | return(_UNKNOWN); 127 | 128 | #endif 129 | 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /src/Utilities/Timer.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | This file is part of ColPack, which is under its License protection. 3 | You should have received a copy of the License. If not, see 4 | 5 | *******************************************************************************/ 6 | 7 | #include "Definitions.h" 8 | 9 | #ifdef SYSTEM_TIME 10 | 11 | #include 12 | 13 | #ifndef CLK_TCK 14 | #define CLK_TCK 100 15 | #endif 16 | 17 | #else 18 | 19 | #include 20 | 21 | #endif 22 | 23 | 24 | #ifndef TIMER_H 25 | #define TIMER_H 26 | 27 | namespace ColPack 28 | { 29 | /** @ingroup group4 30 | * @brief class Timer in @link group4@endlink. 31 | 32 | The timer class is the only class in ColPack which has an optional dependency on the operating 33 | system. It offers both system independent C++ timer based on ctime.h or linux/unix dependent timer based 34 | on sys/times.h. The sytem independent timer only gives wall clock time while linux/unix dependent timer 35 | gives wall, processor, user and system times. 36 | */ 37 | class Timer 38 | { 39 | private: 40 | 41 | /// UNIX only. Used to measure longer execution time. 42 | /** Define SYSTEM_TIME to measure the execution time of a program which may run for more than 30 minutes 43 | (35.79 minutes or 2,147 seconds to be accurate) 44 | Reason: In UNIX, CLOCKS_PER_SEC is defined to be 1,000,000 (In Windows, CLOCKS_PER_SEC == 1,000). 45 | The # of clock-ticks is measured by using variables of type int => max value is 2,147,483,648. 46 | Time in seconds = # of clock-ticks / CLOCKS_PER_SEC => max Time in seconds = 2,147,483,648 / 1,000,000 ~= 2,147 47 | */ 48 | #ifdef SYSTEM_TIME 49 | 50 | struct tms tms_BeginTimer; 51 | struct tms tms_EndTimer; 52 | #endif 53 | 54 | clock_t ct_BeginTimer; 55 | clock_t ct_EndTimer; 56 | 57 | 58 | public: 59 | 60 | //Public Constructor 4351 61 | Timer(); 62 | 63 | //Public Destructor 4352 64 | ~Timer(); 65 | 66 | //Public Function 4354 67 | void Start(); 68 | 69 | //Public Function 4355 70 | void Stop(); 71 | 72 | //Public Function 4356 73 | double GetWallTime(); 74 | 75 | //Public Function 4357 76 | double GetProcessorTime(); 77 | 78 | //Public Function 4358 79 | double GetUserProcessorTime(); 80 | 81 | //Public Function 4359 82 | double GetSystemProcessorTime(); 83 | }; 84 | } 85 | #endif 86 | -------------------------------------------------------------------------------- /src/Utilities/command_line_parameter_processor.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | This file is part of ColPack, which is under its License protection. 3 | You should have received a copy of the License. If not, see 4 | 5 | *******************************************************************************/ 6 | 7 | #include "command_line_parameter_processor.h" 8 | 9 | void createArgs(int argc, const char* argv[], vector& arg) { 10 | for(int i=0;i& arg) { 14 | for (unsigned int i=0; i 5 | *******************************************************************************/ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | using namespace std; 12 | 13 | /*Convert command line parameters to vector arg for easiness 14 | Input: argc, argv 15 | Output: arg 16 | Precondition: arg is empty 17 | */ 18 | void createArgs(int argc, const char* argv[], vector& arg); 19 | 20 | //find argument in vector arg 21 | int findArg(string argument, vector& arg); 22 | 23 | //SAMPLE main.cpp 24 | /* 25 | #include "command_line_parameter_processor.h" 26 | 27 | using namespace std; 28 | 29 | int commandLineProcessing(vector& arg); 30 | 31 | int main(int argc, const char* argv[] ) { 32 | vector arg; 33 | 34 | //get the list of arguments 35 | createArgs(argc, argv, arg); 36 | 37 | //process those arguments 38 | commandLineProcessing(arg); 39 | 40 | //... 41 | 42 | return 0; 43 | } 44 | 45 | int commandLineProcessing(vector& arg) { 46 | 47 | int num=findArg("-r", arg); 48 | if (num!=-1) //argument is found, do something 49 | { 50 | //... 51 | } 52 | 53 | if (findArg("-append", arg) != -1 || findArg("-app", arg) != -1) //append output to the existing file 54 | { 55 | output_append = true; 56 | } 57 | 58 | //"-suffix" has priority over "-suf", i.e., if both "-suffix" and "-suf" are specified, "-suffix " will be used 59 | int result; 60 | result = findArg("-suffix", arg); 61 | if (result == -1) result = findArg("-suf", arg); 62 | if (result != -1) //suffix is specified 63 | { 64 | output_suffix = arg[result+1]; 65 | } 66 | 67 | return 0; 68 | } 69 | //*/ 70 | 71 | 72 | -------------------------------------------------------------------------------- /src/Utilities/current_time.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | This file is part of ColPack, which is under its License protection. 3 | You should have received a copy of the License. If not, see 4 | 5 | *******************************************************************************/ 6 | 7 | #include 8 | #include 9 | 10 | using namespace std; 11 | 12 | #include "current_time.h" 13 | 14 | void current_time() { 15 | time_t curr=time(0); 16 | cout << "Current time is: " << ctime(&curr) < 5 | *******************************************************************************/ 6 | 7 | #ifndef CURRENT_TIME_H 8 | #define CURRENT_TIME_H 9 | 10 | // Display current time 11 | void current_time(); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /src/Utilities/mmio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Matrix Market I/O library for ANSI C 3 | * 4 | * See http://math.nist.gov/MatrixMarket for details. 5 | * 6 | * 7 | */ 8 | 9 | #ifndef MM_IO_H 10 | #define MM_IO_H 11 | 12 | #define MM_MAX_LINE_LENGTH 1025 13 | #define MatrixMarketBanner "%%MatrixMarket" 14 | #define MM_MAX_TOKEN_LENGTH 64 15 | 16 | typedef char MM_typecode[4]; 17 | 18 | char *mm_typecode_to_str(MM_typecode matcode); 19 | 20 | int mm_read_banner(FILE *f, MM_typecode *matcode); 21 | int mm_read_mtx_crd_size(FILE *f, int *M, int *N, int *nz); 22 | int mm_read_mtx_array_size(FILE *f, int *M, int *N); 23 | 24 | int mm_write_banner(FILE *f, MM_typecode matcode); 25 | int mm_write_mtx_crd_size(FILE *f, int M, int N, int nz); 26 | int mm_write_mtx_array_size(FILE *f, int M, int N); 27 | 28 | 29 | /********************* MM_typecode query fucntions ***************************/ 30 | 31 | #define mm_is_matrix(typecode) ((typecode)[0]=='M') 32 | 33 | #define mm_is_sparse(typecode) ((typecode)[1]=='C') 34 | #define mm_is_coordinate(typecode)((typecode)[1]=='C') 35 | #define mm_is_dense(typecode) ((typecode)[1]=='A') 36 | #define mm_is_array(typecode) ((typecode)[1]=='A') 37 | 38 | #define mm_is_complex(typecode) ((typecode)[2]=='C') 39 | #define mm_is_real(typecode) ((typecode)[2]=='R') 40 | #define mm_is_pattern(typecode) ((typecode)[2]=='P') 41 | #define mm_is_integer(typecode) ((typecode)[2]=='I') 42 | 43 | #define mm_is_symmetric(typecode)((typecode)[3]=='S') 44 | #define mm_is_general(typecode) ((typecode)[3]=='G') 45 | #define mm_is_skew(typecode) ((typecode)[3]=='K') 46 | #define mm_is_hermitian(typecode)((typecode)[3]=='H') 47 | 48 | int mm_is_valid(MM_typecode matcode); /* too complex for a macro */ 49 | 50 | 51 | /********************* MM_typecode modify fucntions ***************************/ 52 | 53 | #define mm_set_matrix(typecode) ((*typecode)[0]='M') 54 | #define mm_set_coordinate(typecode) ((*typecode)[1]='C') 55 | #define mm_set_array(typecode) ((*typecode)[1]='A') 56 | #define mm_set_dense(typecode) mm_set_array(typecode) 57 | #define mm_set_sparse(typecode) mm_set_coordinate(typecode) 58 | 59 | #define mm_set_complex(typecode)((*typecode)[2]='C') 60 | #define mm_set_real(typecode) ((*typecode)[2]='R') 61 | #define mm_set_pattern(typecode)((*typecode)[2]='P') 62 | #define mm_set_integer(typecode)((*typecode)[2]='I') 63 | 64 | 65 | #define mm_set_symmetric(typecode)((*typecode)[3]='S') 66 | #define mm_set_general(typecode)((*typecode)[3]='G') 67 | #define mm_set_skew(typecode) ((*typecode)[3]='K') 68 | #define mm_set_hermitian(typecode)((*typecode)[3]='H') 69 | 70 | #define mm_clear_typecode(typecode) ((*typecode)[0]=(*typecode)[1]= \ 71 | (*typecode)[2]=' ',(*typecode)[3]='G') 72 | 73 | #define mm_initialize_typecode(typecode) mm_clear_typecode(typecode) 74 | 75 | 76 | /********************* Matrix Market error codes ***************************/ 77 | 78 | 79 | #define MM_COULD_NOT_READ_FILE 11 80 | #define MM_PREMATURE_EOF 12 81 | #define MM_NOT_MTX 13 82 | #define MM_NO_HEADER 14 83 | #define MM_UNSUPPORTED_TYPE 15 84 | #define MM_LINE_TOO_LONG 16 85 | #define MM_COULD_NOT_WRITE_FILE 17 86 | 87 | 88 | /******************** Matrix Market internal definitions ******************** 89 | 90 | MM_matrix_typecode: 4-character sequence 91 | 92 | ojbect sparse/ data storage 93 | dense type scheme 94 | 95 | string position: [0] [1] [2] [3] 96 | 97 | Matrix typecode: M(atrix) C(oord) R(eal) G(eneral) 98 | A(array) C(omplex) H(ermitian) 99 | P(attern) S(ymmetric) 100 | I(nteger) K(kew) 101 | 102 | ***********************************************************************/ 103 | 104 | #define MM_MTX_STR "matrix" 105 | #define MM_ARRAY_STR "array" 106 | #define MM_DENSE_STR "array" 107 | #define MM_COORDINATE_STR "coordinate" 108 | #define MM_SPARSE_STR "coordinate" 109 | #define MM_COMPLEX_STR "complex" 110 | #define MM_REAL_STR "real" 111 | #define MM_INT_STR "integer" 112 | #define MM_GENERAL_STR "general" 113 | #define MM_SYMM_STR "symmetric" 114 | #define MM_HERM_STR "hermitian" 115 | #define MM_SKEW_STR "skew-symmetric" 116 | #define MM_PATTERN_STR "pattern" 117 | 118 | /* high level routines */ 119 | 120 | int mm_write_mtx_crd(char fname[], int M, int N, int nz, int I[], int J[], 121 | double val[], MM_typecode matcode); 122 | int mm_read_mtx_crd_data(FILE *f, int M, int N, int nz, int I[], int J[], 123 | double val[], MM_typecode matcode); 124 | int mm_read_mtx_crd_entry(FILE *f, int *I, int *J, double *real, double *img, 125 | MM_typecode matcode); 126 | 127 | int mm_read_unsymmetric_sparse(const char *fname, int *M_, int *N_, int *nz_, 128 | double **val_, int **I_, int **J_); 129 | 130 | 131 | 132 | #endif 133 | -------------------------------------------------------------------------------- /src/Utilities/stat.h: -------------------------------------------------------------------------------- 1 | //This file provides the funtions needed to gather statistics about ColPack 2 | #ifndef STAT_H 3 | #define STAT_H 4 | 5 | #include "ColPackHeaders.h" 6 | 7 | using namespace ColPack; 8 | using namespace std; 9 | 10 | 11 | void printListOfGraphs(vector & listOfGraphs, int selected); 12 | vector getListOfGraphs(string location_of_graph_list); 13 | 14 | 15 | void toFileC(string baseDir, string stat_output_suffix, vector Orderings, vector Colorings, map stat_flags ); 16 | 17 | void toFileC_forColoringBasedOrdering(string baseDir, string stat_output_suffix, bool stat_output_append=1, bool stat_refresh_list = false); 18 | 19 | void toFileBiC(string baseDir, string stat_output_suffix, vector Orderings, vector Colorings, map stat_flags ); 20 | 21 | void toFileBiPC(string baseDir, string stat_output_suffix, vector Orderings, vector Colorings, map stat_flags ); 22 | 23 | /* Note: be careful when you work with MatrixMarket-format. 24 | Look inside the file (1st line) to see whether the matrix is: 25 | - 'symmetric': use toFileStatisticForGraph() 26 | - 'general' (likely to be non-symmetric): use toFileStatisticForBipartiteGraph() 27 | //*/ 28 | void toFileStatisticForGraph(string baseDir, string stat_output_suffix, map stat_flags); //i.e. Symmetric Matrix, Hessian 29 | void toFileStatisticForBipartiteGraph(string baseDir, string stat_output_suffix, map stat_flags); //i.e. Matrix, Jacobian 30 | 31 | #endif 32 | --------------------------------------------------------------------------------