Graph Statistics
Utility functions for computing basic structural statistics of a graph.
Defined in: <boost/graph/graph_stats.hpp>
Example
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/graph_stats.hpp>
#include <iostream>
#include <map>
using Graph = boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS>;
int main() {
Graph g(4);
boost::add_edge(0, 1, g);
boost::add_edge(0, 2, g);
boost::add_edge(1, 2, g);
boost::add_edge(0, 1, g); // duplicate edge
unsigned long dups = boost::graph::num_dup_edges(g);
std::cout << "Duplicate edges: " << dups << "\n";
auto dist = boost::graph::degree_dist(g);
std::cout << "Degree distribution:\n";
for (auto& p : dist) {
std::cout << " degree " << p.first << ": " << p.second << " vertices\n";
}
}
Duplicate edges: 1
Degree distribution:
degree 0: 2 vertices
degree 1: 1 vertices
degree 3: 1 vertices
Functions
| Function | What it computes |
|---|---|
|
Number of duplicate (parallel) edges in the graph. |
|
Degree distribution: a |
|
Distribution of duplicate edges per vertex. |
|
Average edge weight by vertex degree. Requires an internal |
Synopsis
namespace boost { namespace graph {
template <typename Graph>
unsigned long num_dup_edges(Graph& g);
template <typename Graph>
std::map<unsigned long, unsigned long> degree_dist(Graph& g);
template <typename Graph>
std::map<unsigned long, unsigned long> dup_edge_dist(Graph& g);
template <typename Graph>
std::map<unsigned long, double> weight_degree_dist(Graph& g);
}}
| Direction | Parameter | Description |
|---|---|---|
IN |
|
Must model VertexListGraph and IncidenceGraph. |