13#include "SubdomainGraphNodes.hpp"
14#include "VTKWriter/VTKWriter.hpp"
64#define BALANCE_CC_O(c) c+1
72template<
typename Graph>
97 Mg.
xadj =
new idx_t[
g.getNVertex() + 1];
107 for (
size_t i = 0; i <
g.getNVertex(); i++)
113 for (
size_t s = 0; s <
g.getNChilds(i); s++)
119 prev +=
g.getNChilds(i);
146 Mg.
xadj =
new idx_t[
g.getNVertex() + 1];
148 Mg.
vwgt =
new idx_t[
g.getNVertex()];
150 Mg.
vsize =
new idx_t[
g.getNVertex()];
159 for (
size_t i = 0; i <
g.getNVertex(); i++)
162 Mg.
vwgt[i] =
g.vertex(i).template get<nm_v_computation>();
164 Mg.
vsize[i] =
g.vertex(i).template get<nm_v_migration>();
171 for (
size_t s = 0; s <
g.getNChilds(i); s++)
176 Mg.
adjwgt[prev + s] =
g.getChildEdge(i, s).template get<nm_e::communication>();
181 prev +=
g.getNChilds(i);
219 Metis(Graph &
g,
size_t nc,
bool useWeights)
335 Mg.
part =
new idx_t[
g.getNVertex()];
337 for (
size_t i = 0; i <
g.getNVertex(); i++)
412 template<
unsigned int i>
418 METIS_PartGraphRecursive(
Mg.
nvtxs,
Mg.
ncon,
Mg.
xadj,
Mg.
adjncy,
Mg.
vwgt,
Mg.
vsize,
Mg.
adjwgt,
Mg.
nparts,
Mg.
tpwgts,
Mg.
ubvec,
Mg.
options,
Mg.
objval,
Mg.
part);
426 auto it =
g.getVertexIterator();
430 g.vertex(it).template get<i>() =
Mg.
part[id];
440 auto it =
g.getVertexIterator();
444 g.vertex(it).template get<i>() = 0;
459 template<
unsigned int i,
typename Graph_part>
463 METIS_PartGraphRecursive(
Mg.
nvtxs,
Mg.
ncon,
Mg.
xadj,
Mg.
adjncy,
Mg.
vwgt,
Mg.
vsize,
Mg.
adjwgt,
Mg.
nparts,
Mg.
tpwgts,
Mg.
ubvec,
Mg.
options,
Mg.
objval,
Mg.
part);
471 auto it = gp.getVertexIterator();
475 gp.vertex(it).template get<i>() =
Mg.
part[id];
494 if (testing ==
false)
Helper class to define Metis graph.
Metis(Graph &g, size_t nc)
Constructor.
void constructAdjList(Graph &g)
Construct Adjacency list.
size_t get_ndec()
Get the decomposition counter.
void decompose()
Decompose the graph.
void onTest(bool testing)
It set Metis on test.
void inc_dec()
Increment the decomposition counter.
void setDistTol(real_t tol)
Distribution tolerance.
size_t n_dec
indicate how many time decompose/refine/re-decompose has been called
void decompose(Graph_part &gp)
Decompose the graph.
Metis(Graph &g, size_t nc, bool useWeights)
Constructor.
Metis_graph Mg
Graph in metis reppresentation.
void constructAdjListWithWeights(Graph &g)
Construct Adjacency list.
Metis(Graph &g)
Constructor.
real_t dist_tol
Distribution tolerance.
void initMetisGraph(int nc, bool useWeights)
Initialize the METIS graph.
idx_t * options
Additional option for the graph partitioning.
idx_t * adjncy
For each vertex it store a list of all neighborhood vertex.
real_t * tpwgts
Desired weight for each partition (one for each constrain)
idx_t * nvtxs
The number of vertices in the graph.
idx_t * vsize
Array of the vertex size, basically is the total communication amount.
real_t * ubvec
For each partition load imbalance tollerated.
idx_t * vwgt
Array that store the weight for each vertex.
idx_t * objval
return the total comunication cost for each partition
idx_t * part
Is a output vector containing the partition for each vertex.
idx_t * nparts
number of part to partition the graph
idx_t * adjwgt
The weight of the edge.
idx_t * xadj
For each vertex it store the adjacency lost start for the vertex i.