Exceptions
BGL algorithms throw these exceptions when preconditions are not met.
Defined in: <boost/graph/exception.hpp>
Example
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/topological_sort.hpp>
#include <boost/graph/exception.hpp>
#include <iostream>
#include <vector>
int main() {
using namespace boost;
using Graph = adjacency_list<vecS, vecS, directedS>;
Graph g(3);
add_edge(0, 1, g);
add_edge(1, 2, g);
add_edge(2, 0, g); // creates a cycle
std::vector<int> order;
try {
topological_sort(g, std::back_inserter(order));
} catch (const not_a_dag& e) {
std::cout << "Exception: " << e.what() << "\n";
}
}
Exception: The graph must be a DAG.
Exception classes
struct bad_graph : public std::invalid_argument {
bad_graph(const std::string& what_arg);
};
struct not_a_dag : public bad_graph {
not_a_dag();
};
struct negative_edge : public bad_graph {
negative_edge();
};
struct negative_cycle : public bad_graph {
negative_cycle();
};
struct not_connected : public bad_graph {
not_connected();
};
| Exception | Thrown when |
|---|---|
|
|
|
|
|
|
|
An algorithm requiring a connected graph receives a disconnected one |