FindSeparator-inl.h
Go to the documentation of this file.
1 /*
2  * FindSeparator-inl.h
3  *
4  * Created on: Nov 23, 2010
5  * Updated: Feb 20. 2014
6  * Author: nikai
7  * Author: Andrew Melim
8  * Description: find the separator of bisectioning for a given graph
9  */
10 
11 #pragma once
12 
13 #include <stdexcept>
14 #include <iostream>
15 #include <vector>
16 #include <optional>
17 #include <boost/shared_array.hpp>
18 
19 #include <gtsam/base/timing.h>
20 
21 #include "FindSeparator.h"
22 
23 #include <metis.h>
24 
25 extern "C" {
26 #include <metislib.h>
27 }
28 
29 
30 
31 namespace gtsam { namespace partition {
32 
33  typedef boost::shared_array<idx_t> sharedInts;
34 
35  /* ************************************************************************* */
42  std::pair<idx_t, sharedInts> separatorMetis(idx_t n, const sharedInts& xadj,
43  const sharedInts& adjncy, const sharedInts& adjwgt, bool verbose) {
44 
45  // control parameters
46  std::vector<idx_t> vwgt; // the weights of the vertices
48  METIS_SetDefaultOptions(options); // use defaults
49  idx_t sepsize; // the size of the separator, output
50  sharedInts part_(new idx_t[n]); // the partition of each vertex, output
51 
52  // set uniform weights on the vertices
53  vwgt.assign(n, 1);
54 
55  // TODO: Fix at later time
56  //boost::timer::cpu_timer TOTALTmr;
57  if (verbose) {
58  printf("**********************************************************************\n");
59  printf("Graph Information ---------------------------------------------------\n");
60  printf(" #Vertices: %d, #Edges: %u\n", n, *(xadj.get()+n) / 2);
61  printf("\nND Partitioning... -------------------------------------------\n");
62  //TOTALTmr.start()
63  }
64 
65  // call metis parition routine
67  &vwgt[0], options, &sepsize, part_.get());
68 
69  if (verbose) {
70  //boost::cpu_times const elapsed_times(timer.elapsed());
71  //printf("\nTiming Information --------------------------------------------------\n");
72  //printf(" Total: \t\t %7.3f\n", elapsed_times);
73  printf(" Sep size: \t\t %d\n", sepsize);
74  printf("**********************************************************************\n");
75  }
76 
77  return std::make_pair(sepsize, part_);
78  }
79 
80  /* ************************************************************************* */
83  {
84  idx_t i, ncon;
85  graph_t *graph;
86  real_t *tpwgts2;
87  ctrl_t *ctrl;
88  ctrl = SetupCtrl(METIS_OP_OMETIS, options, 1, 3, nullptr, nullptr);
89  ctrl->iptype = METIS_IPTYPE_GROW;
90  //if () == nullptr)
91  // return METIS_ERROR_INPUT;
92 
93  InitRandom(ctrl->seed);
94 
95  graph = SetupGraph(ctrl, *nvtxs, 1, xadj, adjncy, vwgt, nullptr, nullptr);
96 
97  AllocateWorkSpace(ctrl, graph);
98 
99  ncon = graph->ncon;
100  ctrl->ncuts = 1;
101 
102  /* determine the weights of the two partitions as a function of the weight of the
103  target partition weights */
104 
105  tpwgts2 = rwspacemalloc(ctrl, 2*ncon);
106  for (i=0; i<ncon; i++) {
107  tpwgts2[i] = rsum((2>>1), ctrl->tpwgts+i, ncon);
108  tpwgts2[ncon+i] = 1.0 - tpwgts2[i];
109  }
110  /* perform the bisection */
111  *edgecut = MultilevelBisect(ctrl, graph, tpwgts2);
112 
113  // ConstructMinCoverSeparator(&ctrl, &graph, 1.05);
114  // *edgecut = graph->mincut;
115  // *sepsize = graph.pwgts[2];
116  icopy(*nvtxs, graph->where, part);
117  std::cout << "Finished bisection:" << *edgecut << std::endl;
118  FreeGraph(&graph);
119 
120  FreeCtrl(&ctrl);
121  }
122 
123  /* ************************************************************************* */
129  std::pair<int, sharedInts> edgeMetis(idx_t n, const sharedInts& xadj, const sharedInts& adjncy,
130  const sharedInts& adjwgt, bool verbose) {
131 
132  // control parameters
133  std::vector<idx_t> vwgt; // the weights of the vertices
135  METIS_SetDefaultOptions(options); // use defaults
136  idx_t edgecut; // the number of edge cuts, output
137  sharedInts part_(new idx_t[n]); // the partition of each vertex, output
138 
139  // set uniform weights on the vertices
140  vwgt.assign(n, 1);
141 
142  //TODO: Fix later
143  //boost::timer TOTALTmr;
144  if (verbose) {
145  printf("**********************************************************************\n");
146  printf("Graph Information ---------------------------------------------------\n");
147  printf(" #Vertices: %d, #Edges: %u\n", n, *(xadj.get()+n) / 2);
148  printf("\nND Partitioning... -------------------------------------------\n");
149  //cleartimer(TOTALTmr);
150  //starttimer(TOTALTmr);
151  }
152 
153  //int wgtflag = 1; // only edge weights
154  //int numflag = 0; // c style numbering starting from 0
155  //int nparts = 2; // partition the graph to 2 submaps
156  modefied_EdgeComputeSeparator(&n, xadj.get(), adjncy.get(), &vwgt[0], adjwgt.get(),
157  options, &edgecut, part_.get());
158 
159 
160  if (verbose) {
161  //stoptimer(TOTALTmr);
162  printf("\nTiming Information --------------------------------------------------\n");
163  //printf(" Total: \t\t %7.3f\n", gettimer(TOTALTmr));
164  printf(" Edge cuts: \t\t %d\n", edgecut);
165  printf("**********************************************************************\n");
166  }
167 
168  return std::make_pair(edgecut, part_);
169  }
170 
171  /* ************************************************************************* */
177  template <class GenericGraph>
178  void prepareMetisGraph(const GenericGraph& graph, const std::vector<size_t>& keys, WorkSpace& workspace,
179  sharedInts* ptr_xadj, sharedInts* ptr_adjncy, sharedInts* ptr_adjwgt) {
180 
181  typedef std::vector<int> Weights;
182  typedef std::vector<int> Neighbors;
183  typedef std::pair<Neighbors, Weights> NeighborsInfo;
184 
185  // set up dictionary
186  std::vector<int>& dictionary = workspace.dictionary;
187  workspace.prepareDictionary(keys);
188 
189  // prepare for {adjacencyMap}, a pair of neighbor indices and the correponding edge weights
190  int numNodes = keys.size();
191  int numEdges = 0;
192  std::vector<NeighborsInfo> adjacencyMap;
193  adjacencyMap.resize(numNodes);
194  std::cout << "Number of nodes: " << adjacencyMap.size() << std::endl;
195  int index1, index2;
196 
197  for(const typename GenericGraph::value_type& factor: graph){
198  index1 = dictionary[factor->key1.index];
199  index2 = dictionary[factor->key2.index];
200  std::cout << "index1: " << index1 << std::endl;
201  std::cout << "index2: " << index2 << std::endl;
202  // if both nodes are in the current graph, i.e. not a joint factor between frontal and separator
203  if (index1 >= 0 && index2 >= 0) {
204  std::pair<Neighbors, Weights>& adjacencyMap1 = adjacencyMap[index1];
205  std::pair<Neighbors, Weights>& adjacencyMap2 = adjacencyMap[index2];
206  try{
207  adjacencyMap1.first.push_back(index2);
208  adjacencyMap1.second.push_back(factor->weight);
209  adjacencyMap2.first.push_back(index1);
210  adjacencyMap2.second.push_back(factor->weight);
211  }catch(std::exception& e){
212  std::cout << e.what() << std::endl;
213  }
214  numEdges++;
215  }
216  }
217 
218  // prepare for {xadj}, {adjncy}, and {adjwgt}
219  *ptr_xadj = sharedInts(new idx_t[numNodes+1]);
220  *ptr_adjncy = sharedInts(new idx_t[numEdges*2]);
221  *ptr_adjwgt = sharedInts(new idx_t[numEdges*2]);
222  sharedInts& xadj = *ptr_xadj;
223  sharedInts& adjncy = *ptr_adjncy;
224  sharedInts& adjwgt = *ptr_adjwgt;
225  int ind_xadj = 0, ind_adjncy = 0;
226  for(const NeighborsInfo& info: adjacencyMap) {
227  *(xadj.get() + ind_xadj) = ind_adjncy;
228  std::copy(info.first .begin(), info.first .end(), adjncy.get() + ind_adjncy);
229  std::copy(info.second.begin(), info.second.end(), adjwgt.get() + ind_adjncy);
230  assert(info.first.size() == info.second.size());
231  ind_adjncy += info.first.size();
232  ind_xadj ++;
233  }
234  if (ind_xadj != numNodes) throw std::runtime_error("prepareMetisGraph_: ind_xadj != numNodes");
235  *(xadj.get() + ind_xadj) = ind_adjncy;
236  }
237 
238  /* ************************************************************************* */
239  template<class GenericGraph>
240  std::optional<MetisResult> separatorPartitionByMetis(const GenericGraph& graph,
241  const std::vector<size_t>& keys, WorkSpace& workspace, bool verbose) {
242  // create a metis graph
243  size_t numKeys = keys.size();
244  if (verbose)
245  std::cout << graph.size() << " factors,\t" << numKeys << " nodes;\t" << std::endl;
246 
248 
249  prepareMetisGraph<GenericGraph>(graph, keys, workspace, &xadj, &adjncy, &adjwgt);
250 
251  // run ND on the graph
252  const auto [sepsize, part] = separatorMetis(numKeys, xadj, adjncy, adjwgt, verbose);
253  if (!sepsize) return std::optional<MetisResult>();
254 
255  // convert the 0-1-2 from Metis to 1-2-0, so that the separator is 0, as later
256  // we will have more submaps
258  result.C.reserve(sepsize);
259  result.A.reserve(numKeys - sepsize);
260  result.B.reserve(numKeys - sepsize);
261  int* ptr_part = part.get();
262  std::vector<size_t>::const_iterator itKey = keys.begin();
263  std::vector<size_t>::const_iterator itKeyLast = keys.end();
264  while(itKey != itKeyLast) {
265  switch(*(ptr_part++)) {
266  case 0: result.A.push_back(*(itKey++)); break;
267  case 1: result.B.push_back(*(itKey++)); break;
268  case 2: result.C.push_back(*(itKey++)); break;
269  default: throw std::runtime_error("separatorPartitionByMetis: invalid results from Metis ND!");
270  }
271  }
272 
273  if (verbose) {
274  std::cout << "total key: " << keys.size()
275  << " result(A,B,C) = " << result.A.size() << ", " << result.B.size() << ", "
276  << result.C.size() << "; sepsize from Metis = " << sepsize << std::endl;
277  //throw runtime_error("separatorPartitionByMetis:stop for debug");
278  }
279 
280  if(result.C.size() != size_t(sepsize)) {
281  std::cout << "total key: " << keys.size()
282  << " result(A,B,C) = " << result.A.size() << ", " << result.B.size() << ", " << result.C.size()
283  << "; sepsize from Metis = " << sepsize << std::endl;
284  throw std::runtime_error("separatorPartitionByMetis: invalid sepsize from Metis ND!");
285  }
286 
287  return result;
288  }
289 
290  /* *************************************************************************/
291  template<class GenericGraph>
292  std::optional<MetisResult> edgePartitionByMetis(const GenericGraph& graph,
293  const std::vector<size_t>& keys, WorkSpace& workspace, bool verbose) {
294 
295  // a small hack for handling the camera1-camera2 case used in the unit tests
296  if (graph.size() == 1 && keys.size() == 2) {
298  result.A.push_back(keys.front());
299  result.B.push_back(keys.back());
300  return result;
301  }
302 
303  // create a metis graph
304  size_t numKeys = keys.size();
305  if (verbose) std::cout << graph.size() << " factors,\t" << numKeys << " nodes;\t" << std::endl;
307  prepareMetisGraph<GenericGraph>(graph, keys, workspace, &xadj, &adjncy, &adjwgt);
308 
309  // run metis on the graph
310  const auto [edgecut, part] = edgeMetis(numKeys, xadj, adjncy, adjwgt, verbose);
311 
312  // convert the 0-1-2 from Metis to 1-2-0, so that the separator is 0, as later we will have more submaps
314  result.A.reserve(numKeys);
315  result.B.reserve(numKeys);
316  int* ptr_part = part.get();
317  std::vector<size_t>::const_iterator itKey = keys.begin();
318  std::vector<size_t>::const_iterator itKeyLast = keys.end();
319  while(itKey != itKeyLast) {
320  if (*ptr_part != 0 && *ptr_part != 1)
321  std::cout << *ptr_part << "!!!" << std::endl;
322  switch(*(ptr_part++)) {
323  case 0: result.A.push_back(*(itKey++)); break;
324  case 1: result.B.push_back(*(itKey++)); break;
325  default: throw std::runtime_error("edgePartitionByMetis: invalid results from Metis ND!");
326  }
327  }
328 
329  if (verbose) {
330  std::cout << "the size of two submaps in the reduced graph: " << result.A.size()
331  << " " << result.B.size() << std::endl;
332  int edgeCut = 0;
333 
334  for(const typename GenericGraph::value_type& factor: graph){
335  int key1 = factor->key1.index;
336  int key2 = factor->key2.index;
337  // print keys and their subgraph assignment
338  std::cout << key1;
339  if (std::find(result.A.begin(), result.A.end(), key1) != result.A.end()) std::cout <<"A ";
340  if (std::find(result.B.begin(), result.B.end(), key1) != result.B.end()) std::cout <<"B ";
341 
342  std::cout << key2;
343  if (std::find(result.A.begin(), result.A.end(), key2) != result.A.end()) std::cout <<"A ";
344  if (std::find(result.B.begin(), result.B.end(), key2) != result.B.end()) std::cout <<"B ";
345  std::cout << "weight " << factor->weight;;
346 
347  // find vertices that were assigned to sets A & B. Their edge will be cut
348  if ((std::find(result.A.begin(), result.A.end(), key1) != result.A.end() &&
349  std::find(result.B.begin(), result.B.end(), key2) != result.B.end()) ||
350  (std::find(result.B.begin(), result.B.end(), key1) != result.B.end() &&
351  std::find(result.A.begin(), result.A.end(), key2) != result.A.end())){
352  edgeCut ++;
353  std::cout << " CUT ";
354  }
355  std::cout << std::endl;
356  }
357  std::cout << "edgeCut: " << edgeCut << std::endl;
358  }
359 
360  return result;
361  }
362 
363  /* ************************************************************************* */
364  bool isLargerIsland(const std::vector<size_t>& island1, const std::vector<size_t>& island2) {
365  return island1.size() > island2.size();
366  }
367 
368  /* ************************************************************************* */
369  // debug functions
370  void printIsland(const std::vector<size_t>& island) {
371  std::cout << "island: ";
372  for(const size_t key: island)
373  std::cout << key << " ";
374  std::cout << std::endl;
375  }
376 
377  void printIslands(const std::list<std::vector<size_t> >& islands) {
378  for(const std::vector<std::size_t>& island: islands)
379  printIsland(island);
380  }
381 
382  void printNumCamerasLandmarks(const std::vector<size_t>& keys, const std::vector<Symbol>& int2symbol) {
383  int numCamera = 0, numLandmark = 0;
384  for(const size_t key: keys)
385  if (int2symbol[key].chr() == 'x')
386  numCamera++;
387  else
388  numLandmark++;
389  std::cout << "numCamera: " << numCamera << " numLandmark: " << numLandmark << std::endl;
390  }
391 
392  /* ************************************************************************* */
393  template<class GenericGraph>
394  void addLandmarkToPartitionResult(const GenericGraph& graph, const std::vector<size_t>& landmarkKeys,
395  MetisResult& partitionResult, WorkSpace& workspace) {
396 
397  // set up cameras in the dictionary
398  std::vector<size_t>& A = partitionResult.A;
399  std::vector<size_t>& B = partitionResult.B;
400  std::vector<size_t>& C = partitionResult.C;
401  std::vector<int>& dictionary = workspace.dictionary;
402  std::fill(dictionary.begin(), dictionary.end(), -1);
403  for(const size_t a: A)
404  dictionary[a] = 1;
405  for(const size_t b: B)
406  dictionary[b] = 2;
407  if (!C.empty())
408  throw std::runtime_error("addLandmarkToPartitionResult: C is not empty");
409 
410  // set up landmarks
411  size_t i,j;
412  for(const typename GenericGraph::value_type& factor: graph) {
413  i = factor->key1.index;
414  j = factor->key2.index;
415  if (dictionary[j] == 0) // if the landmark is already in the separator, continue
416  continue;
417  else if (dictionary[j] == -1)
418  dictionary[j] = dictionary[i];
419  else {
420  if (dictionary[j] != dictionary[i])
421  dictionary[j] = 0;
422  }
423 // if (j == 67980)
424 // std::cout << "dictionary[67980]" << dictionary[j] << std::endl;
425  }
426 
427  for(const size_t j: landmarkKeys) {
428  switch(dictionary[j]) {
429  case 0: C.push_back(j); break;
430  case 1: A.push_back(j); break;
431  case 2: B.push_back(j); break;
432  default: std::cout << j << ": " << dictionary[j] << std::endl;
433  throw std::runtime_error("addLandmarkToPartitionResult: wrong status for landmark");
434  }
435  }
436  }
437 
438 #define REDUCE_CAMERA_GRAPH
439 
440  /* ************************************************************************* */
441  template<class GenericGraph>
442  std::optional<MetisResult> findPartitoning(const GenericGraph& graph, const std::vector<size_t>& keys,
443  WorkSpace& workspace, bool verbose,
444  const std::optional<std::vector<Symbol> >& int2symbol, const bool reduceGraph) {
445  std::optional<MetisResult> result;
446  GenericGraph reducedGraph;
447  std::vector<size_t> keyToPartition;
448  std::vector<size_t> cameraKeys, landmarkKeys;
449  if (reduceGraph) {
450  if (!int2symbol.has_value())
451  throw std::invalid_argument("findSeparator: int2symbol must be valid!");
452 
453  // find out all the landmark keys, which are to be eliminated
454  cameraKeys.reserve(keys.size());
455  landmarkKeys.reserve(keys.size());
456  for(const size_t key: keys) {
457  if((*int2symbol)[key].chr() == 'x')
458  cameraKeys.push_back(key);
459  else
460  landmarkKeys.push_back(key);
461  }
462 
463  keyToPartition = cameraKeys;
464  workspace.prepareDictionary(keyToPartition);
465  const std::vector<int>& dictionary = workspace.dictionary;
466  reduceGenericGraph(graph, cameraKeys, landmarkKeys, dictionary, reducedGraph);
467  std::cout << "original graph: V" << keys.size() << ", E" << graph.size()
468  << " --> reduced graph: V" << cameraKeys.size() << ", E" << reducedGraph.size() << std::endl;
469  result = edgePartitionByMetis(reducedGraph, keyToPartition, workspace, verbose);
470  } else // call Metis to partition the graph to A, B, C
471  result = separatorPartitionByMetis(graph, keys, workspace, verbose);
472 
473  if (!result.has_value()) {
474  std::cout << "metis failed!" << std::endl;
475  return {};
476  }
477 
478  if (reduceGraph) {
479  addLandmarkToPartitionResult(graph, landmarkKeys, *result, workspace);
480  std::cout << "the separator size: " << result->C.size() << " landmarks" << std::endl;
481  }
482 
483  return result;
484  }
485 
486  /* ************************************************************************* */
487  template<class GenericGraph>
488  int findSeparator(const GenericGraph& graph, const std::vector<size_t>& keys,
489  const int minNodesPerMap, WorkSpace& workspace, bool verbose,
490  const std::optional<std::vector<Symbol> >& int2symbol, const bool reduceGraph,
491  const int minNrConstraintsPerCamera, const int minNrConstraintsPerLandmark) {
492 
493  std::optional<MetisResult> result = findPartitoning(graph, keys, workspace,
494  verbose, int2symbol, reduceGraph);
495 
496  // find the island in A and B, and make them separated submaps
497  typedef std::vector<size_t> Island;
498  std::list<Island> islands;
499 
500  std::list<Island> islands_in_A = findIslands(graph, result->A, workspace,
501  minNrConstraintsPerCamera, minNrConstraintsPerLandmark);
502 
503  std::list<Island> islands_in_B = findIslands(graph, result->B, workspace,
504  minNrConstraintsPerCamera, minNrConstraintsPerLandmark);
505 
506  islands.insert(islands.end(), islands_in_A.begin(), islands_in_A.end());
507  islands.insert(islands.end(), islands_in_B.begin(), islands_in_B.end());
508  islands.sort(isLargerIsland);
509  size_t numIsland0 = islands.size();
510 
511 #ifdef NDEBUG
512 // verbose = true;
513 // if (!int2symbol) throw std::invalid_argument("findSeparator: int2symbol is not set!");
514 // std::cout << "sep size: " << result->C.size() << "; ";
515 // printNumCamerasLandmarks(result->C, *int2symbol);
516 // std::cout << "no. of island: " << islands.size() << "; ";
517 // std::cout << "island size: ";
518 // for(const Island& island: islands)
519 // std::cout << island.size() << " ";
520 // std::cout << std::endl;
521 
522 // for(const Island& island: islands) {
523 // printNumCamerasLandmarks(island, int2symbol);
524 // }
525 #endif
526 
527  // absorb small components into the separator
528  size_t oldSize = islands.size();
529  while(true) {
530  if (islands.size() < 2) {
531  std::cout << "numIsland: " << numIsland0 << std::endl;
532  throw std::runtime_error("findSeparator: found fewer than 2 submaps!");
533  }
534 
535  std::list<Island>::reference island = islands.back();
536  if ((int)island.size() >= minNodesPerMap) break;
537  result->C.insert(result->C.end(), island.begin(), island.end());
538  islands.pop_back();
539  }
540  if (islands.size() != oldSize){
541  if (verbose) std::cout << oldSize << "-" << oldSize - islands.size() << " submap(s);\t" << std::endl;
542  }
543  else{
544  if (verbose) std::cout << oldSize << " submap(s);\t" << std::endl;
545  }
546 
547  // generate the node map
548  std::vector<int>& partitionTable = workspace.partitionTable;
549  std::fill(partitionTable.begin(), partitionTable.end(), -1);
550  for(const size_t key: result->C)
551  partitionTable[key] = 0;
552  int idx = 0;
553  for(const Island& island: islands) {
554  idx++;
555  for(const size_t key: island) {
556  partitionTable[key] = idx;
557  }
558  }
559 
560  return islands.size();
561  }
562 
563 }} //namespace
key1
const Symbol key1('v', 1)
timing.h
Timing utilities.
gtsam::partition::reduceGenericGraph
void reduceGenericGraph(const GenericGraph3D &graph, const std::vector< size_t > &cameraKeys, const std::vector< size_t > &landmarkKeys, const std::vector< int > &dictionary, GenericGraph3D &reducedGraph)
Definition: GenericGraph.cpp:353
FreeCtrl
#define FreeCtrl
Definition: rename.h:198
gtsam::partition::findPartitoning
std::optional< MetisResult > findPartitoning(const GenericGraph &graph, const std::vector< size_t > &keys, WorkSpace &workspace, bool verbose, const std::optional< std::vector< Symbol > > &int2symbol, const bool reduceGraph)
Definition: FindSeparator-inl.h:442
gtsam::partition::WorkSpace::dictionary
std::vector< int > dictionary
Definition: PartitionWorkSpace.h:20
gtsam::partition::WorkSpace
Definition: PartitionWorkSpace.h:19
adjwgt
idx_t idx_t idx_t idx_t idx_t idx_t * adjwgt
Definition: include/metis.h:198
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
keys
const KeyVector keys
Definition: testRegularImplicitSchurFactor.cpp:40
FindSeparator.h
ctrl_t
Definition: libmetis/struct.h:139
gtsam::partition::prepareMetisGraph
void prepareMetisGraph(const GenericGraph &graph, const std::vector< size_t > &keys, WorkSpace &workspace, sharedInts *ptr_xadj, sharedInts *ptr_adjncy, sharedInts *ptr_adjwgt)
Definition: FindSeparator-inl.h:178
gtsam::partition::WorkSpace::partitionTable
PartitionTable partitionTable
Definition: PartitionWorkSpace.h:22
adjncy
idx_t idx_t idx_t * adjncy
Definition: include/metis.h:198
AllocateWorkSpace
#define AllocateWorkSpace
Definition: rename.h:250
B
Definition: test_numpy_dtypes.cpp:299
gtsam::partition::modefied_EdgeComputeSeparator
void modefied_EdgeComputeSeparator(idx_t *nvtxs, idx_t *xadj, idx_t *adjncy, idx_t *vwgt, idx_t *adjwgt, idx_t *options, idx_t *edgecut, idx_t *part)
Definition: FindSeparator-inl.h:81
ctrl_t::tpwgts
real_t * tpwgts
Definition: libmetis/struct.h:169
result
Values result
Definition: OdometryOptimize.cpp:8
gtsam::partition::printNumCamerasLandmarks
void printNumCamerasLandmarks(const std::vector< size_t > &keys, const std::vector< Symbol > &int2symbol)
Definition: FindSeparator-inl.h:382
n
int n
Definition: BiCGSTAB_simple.cpp:1
METIS_ComputeVertexSeparator
int METIS_ComputeVertexSeparator(idx_t *nvtxs, idx_t *xadj, idx_t *adjncy, idx_t *vwgt, idx_t *options, idx_t *r_sepsize, idx_t *part)
Definition: parmetis.c:161
MultilevelBisect
#define MultilevelBisect
Definition: rename.h:208
ncon
idx_t * ncon
Definition: include/metis.h:197
A
Definition: test_numpy_dtypes.cpp:298
key2
const Symbol key2('v', 2)
ctrl_t::iptype
miptype_et iptype
Definition: libmetis/struct.h:144
j
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2
METIS_IPTYPE_GROW
@ METIS_IPTYPE_GROW
Definition: include/metis.h:321
SetupGraph
#define SetupGraph
Definition: rename.h:90
gtsam::partition::separatorPartitionByMetis
std::optional< MetisResult > separatorPartitionByMetis(const GenericGraph &graph, const std::vector< size_t > &keys, WorkSpace &workspace, bool verbose)
Definition: FindSeparator-inl.h:240
InitRandom
#define InitRandom
Definition: rename.h:246
gtsam::partition::printIslands
void printIslands(const std::list< std::vector< size_t > > &islands)
Definition: FindSeparator-inl.h:377
gtsam::Weights
Eigen::Matrix< double, 1, -1 > Weights
Definition: Basis.h:69
gtsam::partition::MetisResult::C
std::vector< size_t > C
Definition: FindSeparator.h:25
info
else if n * info
Definition: 3rdparty/Eigen/lapack/cholesky.cpp:18
SetupCtrl
#define SetupCtrl
Definition: rename.h:194
gtsam::partition::findIslands
list< vector< size_t > > findIslands(const GenericGraph2D &graph, const vector< size_t > &keys, WorkSpace &workspace, const int minNrConstraintsPerCamera, const int minNrConstraintsPerLandmark)
Definition: GenericGraph.cpp:23
METIS_OP_OMETIS
@ METIS_OP_OMETIS
Definition: include/metis.h:265
vwgt
idx_t idx_t idx_t idx_t * vwgt
Definition: include/metis.h:198
gtsam::partition::WorkSpace::prepareDictionary
void prepareDictionary(const std::vector< size_t > &keys)
Definition: PartitionWorkSpace.h:29
part
idx_t idx_t idx_t idx_t idx_t idx_t idx_t real_t real_t idx_t idx_t idx_t * part
Definition: include/metis.h:200
edgecut
idx_t idx_t idx_t idx_t idx_t idx_t idx_t real_t real_t idx_t idx_t * edgecut
Definition: include/metis.h:200
gtsam::partition::MetisResult::B
std::vector< size_t > B
Definition: FindSeparator.h:24
key
const gtsam::Symbol key('X', 0)
gtsam::partition::sharedInts
boost::shared_array< idx_t > sharedInts
Definition: FindSeparator-inl.h:33
gtsam::b
const G & b
Definition: Group.h:79
METIS_SetDefaultOptions
int METIS_SetDefaultOptions(idx_t *options)
Definition: auxapi.c:36
xadj
idx_t idx_t * xadj
Definition: include/metis.h:197
a
ArrayXXi a
Definition: Array_initializer_list_23_cxx11.cpp:1
C
Matrix< Scalar, Dynamic, Dynamic > C
Definition: bench_gemm.cpp:50
gtsam
traits
Definition: SFMdata.h:40
FreeGraph
#define FreeGraph
Definition: rename.h:98
gtsam::partition::separatorMetis
std::pair< idx_t, sharedInts > separatorMetis(idx_t n, const sharedInts &xadj, const sharedInts &adjncy, const sharedInts &adjwgt, bool verbose)
Definition: FindSeparator-inl.h:42
gtsam::partition::printIsland
void printIsland(const std::vector< size_t > &island)
Definition: FindSeparator-inl.h:370
ctrl_t::seed
idx_t seed
Definition: libmetis/struct.h:156
gtsam::partition::edgeMetis
std::pair< int, sharedInts > edgeMetis(idx_t n, const sharedInts &xadj, const sharedInts &adjncy, const sharedInts &adjwgt, bool verbose)
Definition: FindSeparator-inl.h:129
rsum
#define rsum
Definition: gklib_rename.h:117
real_t
float real_t
Definition: include/metis.h:132
METIS_NOPTIONS
#define METIS_NOPTIONS
Definition: include/metis.h:175
metislib.h
ctrl_t::ncuts
idx_t ncuts
Definition: libmetis/struct.h:157
gtsam::partition::edgePartitionByMetis
std::optional< MetisResult > edgePartitionByMetis(const GenericGraph &graph, const std::vector< size_t > &keys, WorkSpace &workspace, bool verbose)
Definition: FindSeparator-inl.h:292
sepsize
idx_t idx_t idx_t idx_t idx_t * sepsize
Definition: include/metis.h:237
gtsam::partition::isLargerIsland
bool isLargerIsland(const std::vector< size_t > &island1, const std::vector< size_t > &island2)
Definition: FindSeparator-inl.h:364
icopy
#define icopy
Definition: gklib_rename.h:28
graph
NonlinearFactorGraph graph
Definition: doc/Code/OdometryExample.cpp:2
gtsam::partition::MetisResult
Definition: FindSeparator.h:23
gtsam::partition::MetisResult::A
std::vector< size_t > A
Definition: FindSeparator.h:24
options
Definition: options.h:16
i
int i
Definition: BiCGSTAB_step_by_step.cpp:9
rwspacemalloc
#define rwspacemalloc
Definition: rename.h:257
graph_t
Definition: libmetis/struct.h:82
idx_t
int32_t idx_t
Definition: include/metis.h:101
gtsam::partition::addLandmarkToPartitionResult
void addLandmarkToPartitionResult(const GenericGraph &graph, const std::vector< size_t > &landmarkKeys, MetisResult &partitionResult, WorkSpace &workspace)
Definition: FindSeparator-inl.h:394
gtsam::partition::findSeparator
int findSeparator(const GenericGraph &graph, const std::vector< size_t > &keys, const int minNodesPerMap, WorkSpace &workspace, bool verbose, const std::optional< std::vector< Symbol > > &int2symbol, const bool reduceGraph, const int minNrConstraintsPerCamera, const int minNrConstraintsPerLandmark)
Definition: FindSeparator-inl.h:488


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:02:17