@@ -295,34 +295,30 @@ void GraphPartitioner::readPartitionFile(const std::string &file_name, Partition
295295
296296void GraphPartitioner::partitionUsingScotch (Partition &partition)
297297{
298- SCOTCH_Graph *graph_sc = SCOTCH_graphAlloc ();
299- if (graph_sc == nullptr ) {
300- std::cerr << " Error allocating graph" << std::endl;
298+ SCOTCH_Graph graph_sc;
299+ SCOTCH_Strat strat;
300+
301+ SCOTCH_graphInit (&graph_sc);
302+ SCOTCH_stratInit (&strat);
303+
304+ if (SCOTCH_stratGraphMapBuild (&strat, SCOTCH_STRATQUALITY, _nbr_parts, 0.05 )) {
305+ std::cerr << " Error building graph partition strategy" << std::endl;
301306 return ;
302307 }
303308
304- SCOTCH_Strat *strat = SCOTCH_stratAlloc ();
305- if (SCOTCH_stratInit (strat)) {
306- std::cerr << " Error allocating graph" << std::endl;
307- return ;
309+ if (SCOTCH_graphBuild (&graph_sc, 0 , _nbr_vtxs, _xadj.data (), NULL , NULL , NULL , _edges, _adjncy.data (), NULL ) != 0 ) {
310+ std::cerr << " Error: Scotch Graph Build" << std::endl;
311+ return ;
308312 }
309313
310- if (SCOTCH_stratGraphMapBuild (strat, SCOTCH_STRATDEFAULT, 4 , 0.05 ) ) {
311- std::cerr << " Error allocating graph " << std::endl;
312- return ;
314+ if (SCOTCH_graphPart (&graph_sc, _nbr_parts, &strat, partition. values . data ()) != 0 ) {
315+ std::cerr << " Error: Scotch Graph Partition " << std::endl;
316+ return ;
313317 }
314318
315- if (SCOTCH_graphBuild (graph_sc, 0 , _nbr_vtxs, _xadj.data (), nullptr , _vwgt.data (), nullptr , _edges, _adjncy.data (), _ewgt.data ()) != 0 ) {
316- std::cerr << " Error: Scotch Graph Build" << std::endl;
317- return ;
318- }
319- if (SCOTCH_graphPart (graph_sc, _nbr_parts, strat, partition.values .data ()) != 0 ) {
320- std::cerr << " Error: Scotch Graph Partition" << std::endl;
321- return ;
322- }
319+ SCOTCH_stratExit (&strat);
320+ SCOTCH_graphExit (&graph_sc);
323321
324- SCOTCH_stratExit (strat);
325- SCOTCH_graphFree (graph_sc);
326322}
327323
328324void GraphPartitioner::partitionUsingKaHip (Partition &partition)
0 commit comments