1 #ifndef GL_HAVEL_HAKIMI_HPP
2 #define GL_HAVEL_HAKIMI_HPP
19 std::sort(degrees.begin(), degrees.end(), [](idx_t a, idx_t b){
24 if (degrees.back() < 0)
return false;
26 if (degrees.front() > degrees.size() - 1)
return false;
28 if (std::accumulate(degrees.begin(),degrees.end(), 0) % 2)
return false;
30 if (!degrees.front())
return true;
32 auto degree = degrees.front();
35 for (idx_t i = 0; i < degree; ++i) {
50 std::stringstream iss(degreeSeq);
53 while( iss >> degree )
54 degrees.push_back(degree);
62 #endif // GL_HAVEL_HAKIMI_HPP
Graph::idx_list_t degrees(const Graph &graph)
Computes the out-degrees of all nodes in a graph.
Definition: Degrees.hpp:16
std::size_t index_type
Definition: gl_base.hpp:18
bool isGraphicSequence(const std::string °reeSeq)
Uses the Havel-Hakimi algorithm to determine whether a given degree sequence is graphic.
Definition: HavelHakimi.hpp:47
bool havelHakimi(std::deque< gl::index_type > degrees)
Uses the Havel-Hakimi algorithm to determine whether a given degree sequence is graphic.
Definition: HavelHakimi.hpp:16