KarypisLab / METIS

METIS - Serial Graph Partitioning and Fill-reducing Matrix Ordering

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

seg fault when npart = 1

alfredojaramillo opened this issue · comments

both METIS_PartGraphRecursive and METIS_PartGraphKway fail when npart = 1 in Fedora 37 and Fedora 39 (gcc 13.2.1).

METIS_PartGraphKway throws seg fault whereas METIS_PartGraphRecursive hangs up.

The following example code reproduces the issue:

    #include <metis.h>
    #include <iostream>
    #include <vector>
    
    int main() {

    int nVertices = 6;
    int nEdges = 7;
    
    std::vector<int> xadj = {0, 2, 4, 6, 8, 10, 12};
    std::vector<int> adjncy = {1, 2, 0, 2, 3, 1, 3, 4, 2, 4, 5, 3, 5};
    
    int options[METIS_NOPTIONS];
    METIS_SetDefaultOptions(options);
    
    std::vector<int> partition(nVertices);
    
    int nParts = 1;
    
    std::vector<int> objval(1); 
    std::vector<int> part(nVertices);
    

    METIS_PartGraphRecursive(&nVertices, &nEdges, xadj.data(), adjncy.data(), NULL, NULL, NULL, &nParts, NULL, NULL, options, &objval[0], &part[0]);

    //METIS_PartGraphKway(&nVertices, &nEdges, xadj.data(), adjncy.data(), NULL, NULL, NULL, &nParts, NULL, NULL, options, &objval[0], &part[0]);
    
    std::cout << "Partitioning Result:" << std::endl;
    for (int i = 0; i < nVertices; ++i) {
        std::cout << "Node " << i+1 << " is in partition " << part[i] + 1 << std::endl;
    }
    
    return 0;
}

this may be related to #67 ?