Aleph-w  1.9
General library for algorithms and data structures
single_graph.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 SINGLE_GRAPH_H
28 # define SINGLE_GRAPH_H
29 
30 # include <tpl_dynSetTree.H>
31 
32 namespace Aleph {
33 
46 template <class GT,
47  class SN = Dft_Show_Node<GT>,
48  class SA = Dft_Show_Arc<GT> >
50 {
51  SN & sn;
52  SA & sa;
53 
54  typedef typename GT::Node GT_Node;
55 
56 public:
57 
58  Test_Single_Graph(SN && __sn = SN(), SA && __sa = SA())
59  : sn(__sn), sa(__sa)
60  {
61  // empty
62  }
63 
65  bool test_node(typename GT::Node * p)
66  {
68 
69  for (Node_Arc_Iterator<GT, SA> it(p, sa); it.has_curr(); it.next_ne())
70  {
71  GT_Node * q = it.get_tgt_node_ne();
72  if (nodes.exist(q))
73  return false;
74  else
75  nodes.insert(p);
76  }
77 
78  return true;
79  }
80 
81  bool operator () (GT & g)
82  {
83  for (Node_Iterator<GT, SN> it(g, sn); it.has_curr(); it.next_ne())
84  if (not test_node(it.get_curr_ne()))
85  return false;
86 
87  return true;
88  }
89 };
90 
91 
92 
93 } // end namespace Aleph
94 
95 # endif // SINGLE_GRAPH_H_H
Definition: tpl_dynSetTree.H:961
Definition: tpl_graph.H:1257
Definition: ah-comb.H:35
Definition: single_graph.H:49
Definition: tpl_graph.H:1063
bool exist(const Key &key) const
Retorna true si key pertenece al conjunto dinámico.
Definition: tpl_dynSetTree.H:385
Definition: tpl_graph.H:1270
Definition: tpl_graph.H:1177
bool test_node(typename GT::Node *p)
retorna true si p no tiene multiarcos ni lazos
Definition: single_graph.H:65
Key * insert(const Key &key)
Definition: tpl_dynSetTree.H:195

Leandro Rabindranath León