Aleph-w  1.9
General library for algorithms and data structures
tpl_test_connectivity.H
1 
2 /* Aleph-w
3 
4  / \ | | ___ _ __ | |__ __ __
5  / _ \ | |/ _ \ '_ \| '_ \ ____\ \ /\ / / Data structures & Algorithms
6  / ___ \| | __/ |_) | | | |_____\ V V / version 1.9b
7  /_/ \_\_|\___| .__/|_| |_| \_/\_/ https://github.com/lrleon/Aleph-w
8  |_|
9 
10  This file is part of Aleph-w library
11 
12  Copyright (c) 2002-2018 Leandro Rabindranath Leon & Alejandro Mujica
13 
14  This program is free software: you can redistribute it and/or modify
15  it under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  This program is distributed in the hope that it will be useful, but
20  WITHOUT ANY WARRANTY; without even the implied warranty of
21  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22  General Public License for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with this program. If not, see <https://www.gnu.org/licenses/>.
26 */
27 # ifndef TPL_TEST_CONNECTIVITY_H
28 # define TPL_TEST_CONNECTIVITY_H
29 
30 # include <tpl_graph_utils.H>
31 
32 
53  template <class GT, class SA = Dft_Show_Arc<GT> >
55 {
56 public:
57 
70  bool operator () (GT & g, SA && sa = SA()) const
71  {
72  if (g.is_digraph()) // sólo es válida para grafos, no digrafos
73  throw std::domain_error("test_connectivity() does not work on digraphs");
74 
75  if (g.get_num_arcs() < g.get_num_nodes() - 1)
76  return false;
77 
79 
80  return traversal(g) == g.get_num_nodes();
81  }
82 
95  bool operator () (GT & g, SA & sa) const
96  {
97  if (g.is_digraph()) // sólo es válida para grafos, no digrafos
98  throw std::domain_error("test_connectivity() does not work on digraphs");
99 
100  if (g.get_num_arcs() < g.get_num_nodes() - 1)
101  return false;
102 
104 
105  return traversal(g) == g.get_num_nodes();
106  }
107 };
108 
109 
110 
111 # endif // TPL_TEST_CONNECTIVITY_H
Definition: tpl_graph_utils.H:138
Definition: tpl_test_connectivity.H:54
bool operator()(GT &g, SA &&sa=SA()) const
Definition: tpl_test_connectivity.H:70

Leandro Rabindranath León