Untitled

mail@pastecode.io avatar
unknown
c_cpp
24 days ago
773 B
2
Indexable
Never
std::vector< int > Graph::slfColoring()
{
    std::vector< int > verticesColours( number_of_vertices, -1 );

    std::vector<bool> availableColours( number_of_vertices, true );

    std::vector< std::pair< int, int > > verticesWithDegree;
    verticesWithDegree.reserve( number_of_vertices );

    std::vector< int > degrees = degreeSequence();

    for( int u = 0; u < number_of_vertices; ++u )
    {
        verticesWithDegree.emplace_back( u, degrees[ u ] );
    }

    std::sort(verticesWithDegree.begin(), verticesWithDegree.end(), []
    ( const auto &a, const auto &b)
        {
            if( a.second != b.second )
                return a.second > b.second;
            else
                return a.first < b.first;
        }
    );
}
Leave a Comment