GraphLibrary  0.0.1
A simple library that implements various graph algorithms.
 All Classes Namespaces Files Functions Variables Typedefs Macros
DegreeSequence.hpp
Go to the documentation of this file.
1 #ifndef GL_DEGREE_SEQUENCE_HPP
2 #define GL_DEGREE_SEQUENCE_HPP
3 
4 #include "../structures/Graph.hpp"
5 #include "Degrees.hpp"
6 
7 namespace gl {
8 namespace algorithm {
9 
16 template <class SCALAR, class STORAGE_KIND, class DIR, GL_ENABLE_IF_UNDIRECTED_T>
18  using GRAPH = Graph<SCALAR,STORAGE_KIND,DIR>;
19  if (graph.isDirected()) {
20  throw std::logic_error("Graph is not undirected.");
21  }
22  typename GRAPH::idx_list_t out = gl::algorithm::degrees(graph);
23  std::sort(out.begin(), out.end(), std::greater<typename GRAPH::idx_t>());
24  return out;
25 }
26 
27 } // namespace algorithm
28 } // namespace gl
29 
30 #endif // GL_DEGREE_SEQUENCE_HPP
std::vector< idx_t > idx_list_t
Index List type.
Definition: Graph.hpp:48
Stores and implements a Graph.
Definition: Graph.hpp:39
Graph< SCALAR, STORAGE_KIND, DIR >::idx_list_t degreeSequence(const Graph< SCALAR, STORAGE_KIND, DIR > &graph)
Computes the out-degree of all nodes in an undirected graph. The resulting list is sorted by descendi...
Definition: DegreeSequence.hpp:17
bool isDirected() const
Returns true if the graph is directed, false if not.
Definition: Graph.hpp:426
Graph::idx_list_t degrees(const Graph &graph)
Computes the out-degrees of all nodes in a graph.
Definition: Degrees.hpp:16