1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
#include "includes.h"
#include "typedefs.h"
#include "mesh.h"
#include "node.h"
#include "element.h"
#include "mpi_call.h"
#include "vector"
#include "sparsematrixstructure.h"
#include "sparsematrix.h"
#include "assembler.h"
#include "blas.h"
#include<map>
#include<set>
#include <unordered_map>
#include<metis.h>
int main() {
idx_t nVertices = 6;
idx_t nEdges = 7;
idx_t nWeights = 1;
idx_t nParts = 2;
idx_t objval;
std::vector<idx_t> part(nVertices, 0);
// Indexes of starting points in adjacent array
std::vector<idx_t> xadj = { 0,2,5,7,9,12,14 };
std::vector<idx_t> adjncy = { 1,3,0,4,2,1,5,0,4,3,1,5,4,2 };
std::vector<idx_t> vwgt(nVertices * nWeights, 0);
int ret = METIS_PartGraphKway(&nVertices, &nWeights, xadj.data(), adjncy.data(),
NULL, NULL, NULL, &nParts, NULL,
NULL, NULL, &objval, part.data());
std::cout << ret << std::endl;
for (unsigned part_i = 0; part_i < part.size(); part_i++) {
std::cout << part_i << " " << part[part_i] << std::endl;
}
}
|