21 throw std::invalid_argument(
"order must be greater than 0.");
25 void add_edge(index_t i, index_t j) {
32 index_t degree(index_t i)
const {
33 return m_.col(i).cast<index_t>().sum() + m_.row(i).cast<index_t>().sum() - m_(i, i);
36 bool has_edge(index_t i, index_t j)
const {
43 bool is_connected()
const {
44 std::vector<bool> visited(order());
45 std::stack<index_t> to_visit;
49 while (!to_visit.empty()) {
50 auto i = to_visit.top();
55 for (index_t j = 0; j < order(); j++) {
56 if (has_edge(i, j) && !visited.at(j)) {
62 return std::find(visited.begin(), visited.end(),
false) == visited.end();
65 bool is_simple()
const {
66 for (index_t i = 0; i < order(); i++) {
71 for (index_t j = i + 1; j < order(); j++) {
81 index_t max_degree()
const {
83 for (index_t i = 0; i < order(); i++) {
84 max_degree = std::max(max_degree, degree(i));
89 index_t order()
const {
return m_.rows(); }