Author |
Message |
dyah
| Posted on Tuesday, July 19, 2005 - 11:44 pm: | |
Hello ..., I have a problem when I'm trying to use libhmetis.lib (version 1.5.3) in Microsoft Visual C++ 6.0. After I've run it, the partition results were always produce only one partition whatever the Nparts has been assigned. The Part (partition number) were always show the last number of desired partition, if (Nparts = N) then (all Part = (N-1)). For example : I try to implement hypergraph Figure 5(b) in page 13 of HMETIS manual documentation as define bellow : nvtxs = 7; nhedges = 4; ubfactor = 5; eptr = {0,2,6,9,12}; eind = {0,1,0,4,5,6,3,4,5,1,2,3}; hewgts = {2,3,8,7}; vwgts = NULL Result : nparts = 2; egdecut = 0 ; part = {1,1,1,1,1,1,1} nparts = 3; egdecut = 0 ; part = {2,2,2,2,2,2,2} ... Cloud you tell why it happen, please ? Was I make somes mistakes when implementing it ? A lot of thanks for you before.... ( DYAH ) =================================================== //cobaterus4vec.cxx #include <iostream.h> #include <vector> using namespace std; #include "assert.h" extern "C" { void HMETIS_PartRecursive(int nvtxs, int nhedges, int *vwgts, int *eptr, int *eind, int *hewgts, int nparts, int ubfactor, int *options, int *part, int *edgecut); }; class chmetis { public : int* CreateIntArray(const vector<int> &input); }; int main() { cout << "hello"<< endl; chmetis hh; int nvtxs_, nhedges_, nparts_, edgecut_, ubfactor_, i; nvtxs_ = 7; nhedges_ = 4; nparts_ = 3; ubfactor_ = 5; vector<int> vwgts_; vector<int> eptr_; vector<int> eind_; vector<int> hewgts_; vector<int> options_; vector<int> part_; for ( i = 0 ; i < nvtxs_ ; i++) { vwgts_.push_back(NULL); part_.push_back(-1); } // eptr_ = {0,2,6,9,12}; eptr_.push_back(0); eptr_.push_back(2); eptr_.push_back(6); eptr_.push_back(9); eptr_.push_back(12); // eind_ = {0,1,0,4,5,6,3,4,5,1,2,3}; eind_.push_back(0); eind_.push_back(1); eind_.push_back(0); eind_.push_back(4); eind_.push_back(5); eind_.push_back(6); eind_.push_back(3); eind_.push_back(4); eind_.push_back(5); eind_.push_back(1); eind_.push_back(2); eind_.push_back(3); // hewgts_ = {2,3,8,7}; hewgts_.push_back(2); hewgts_.push_back(3); hewgts_.push_back(4); hewgts_.push_back(8); hewgts_.push_back(7); options_.resize(9); options_[0] = 1; //default or no options_[1] = 10;//Nruns options_[2] = 1;//Ctype options_[3] = 1;//Rtype options_[4] = 1;//Vcycle options_[5] = 0;//Reconst options_[6] = 0;//pre-assign modules OFF options_[7] = -1;//Random seed options_[8] = 0;//dbglvl int *vwgts_array = hh.CreateIntArray(vwgts_); int *eptr_array = hh.CreateIntArray(eptr_); int *eind_array = hh.CreateIntArray(eind_); int *hewgts_array = hh.CreateIntArray(hewgts_); int *options_array = hh.CreateIntArray(options_); int *part_array = hh.CreateIntArray(part_); cout << "nparts : " << nparts_ << endl; HMETIS_PartRecursive(nvtxs_, nhedges_, vwgts_array, eptr_array, eind_array, hewgts_array, nparts_, ubfactor_, options_array, part_array, &edgecut_) ; cout << "Edge cut : "<< edgecut_ <<endl<<"parts : "<<endl; //?? for (i=0; i<nvtxs_ ;i++) { cout<<i<<". "<<part_array[i]<<endl; } return 0; } int* chmetis::CreateIntArray(const vector<int> &input) { int* new_array = new int[input.size()]; for(int i=0; i<input.size(); i++) new_array[i] = input[i]; return new_array; } ==================================================== |
|