| 436 | |
| 437 | #ifdef USEMETIS |
| 438 | void reduced_nd_fast(int* n, |
| 439 | kahip_idx* xadj, |
| 440 | kahip_idx* adjncy, |
| 441 | bool suppress_output, |
| 442 | int seed, |
| 443 | int* ordering) { |
| 444 | std::streambuf* backup = std::cout.rdbuf(); |
| 445 | if(suppress_output) { |
| 446 | std::cout.rdbuf(nullptr); |
| 447 | } |
| 448 | |
| 449 | configuration cfg; |
| 450 | PartitionConfig partition_config; |
| 451 | partition_config.k = 2; |
| 452 | partition_config.dissection_rec_limit = 120; |
| 453 | partition_config.max_simplicial_degree = 12; |
| 454 | partition_config.disable_reductions = false; |
| 455 | partition_config.convergence_factor = 1; |
| 456 | partition_config.reduction_order = {simplicial_nodes, degree_2_nodes}; |
| 457 | |
| 458 | partition_config.seed = seed; |
| 459 | srand(partition_config.seed); |
| 460 | random_functions::setSeed(partition_config.seed); |
| 461 | partition_config.seed = seed; |
| 462 | |
| 463 | graph_access input_graph; |
| 464 | internal_build_graph( partition_config, n, nullptr, xadj, nullptr, adjncy, input_graph); |
| 465 | |
| 466 | // 'active_graph' is the graph to use after reductions have been applied. |
| 467 | // If no reductions have been applied, 'active_graph' points to 'input_graph'. |
| 468 | // Otherwise, it points to 'reduction_stack.back()->get_reduced_graph()'. |
| 469 | graph_access *active_graph; |
| 470 | std::vector<std::unique_ptr<Reduction>> reduction_stack; |
| 471 | bool used_reductions = apply_reductions(partition_config, input_graph, reduction_stack); |
| 472 | if (used_reductions) { |
| 473 | active_graph = &reduction_stack.back()->get_reduced_graph(); |
| 474 | } else { |
| 475 | active_graph = &input_graph; |
| 476 | } |
| 477 | |
| 478 | idx_t num_nodes = active_graph->number_of_nodes(); |
| 479 | // convert the graph into metis-style |
| 480 | idx_t* m_xadj = new idx_t[num_nodes + 1]; |
| 481 | forall_nodes((*active_graph), node) { |
| 482 | m_xadj[node] = (idx_t)active_graph->get_first_edge(node); |
| 483 | } endfor |
| 484 | m_xadj[num_nodes] = (idx_t)active_graph->number_of_edges(); |
| 485 | idx_t* m_adjncy = new idx_t[active_graph->number_of_edges()]; |
| 486 | forall_edges((*active_graph), edge) { |
| 487 | m_adjncy[edge] = (idx_t)active_graph->getEdgeTarget(edge); |
| 488 | } endfor |
| 489 | |
| 490 | idx_t* m_perm = new idx_t[active_graph->number_of_nodes()]; |
| 491 | idx_t* m_iperm = new idx_t[active_graph->number_of_nodes()]; // inverse ordering. This is the one we are interested in. |
| 492 | idx_t* metis_options = new idx_t[METIS_NOPTIONS]; |
| 493 | |
| 494 | // Perform nested dissection with Metis |
| 495 | if (num_nodes > 0) { |
nothing calls this directly
no test coverage detected