Aleph-w  1.9
General library for algorithms and data structures
warshall.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 
28 # ifndef WARSHALL_H
29 # define WARSHALL_H
30 
31 # include <tpl_graph.H>
32 # include <tpl_matgraph.H>
33 
34 namespace Aleph {
35 
59  template <class GT, class SA = Dft_Show_Arc<GT> >
62 {
63  Bit_Mat_Graph<GT, SA> mat_prev(g);
64  if (mat.get_list_graph() != &g)
65  mat.set_list_graph(g);
66  const size_t & n = mat.get_num_nodes();
67  for (int k = 0; k < n; k++)
68  {
69  for (int i = 0; i < n; i++)
70  for (int j = 0; j < n; j++)
71  mat(i, j) = mat_prev(i, j) or
72  (mat_prev(i, k) and mat_prev(k, j));
73 
74  mat_prev = mat;
75  }
76 }
77 
93  template <class GT, class SA = Dft_Show_Arc<GT> >
95 {
96 public:
97 
109  void operator () (GT & g, Bit_Mat_Graph<GT> & mat) const
110  {
111  warshall_compute_transitive_clausure <GT, SA> (g, mat);
112  }
113 };
114 
115 } // end namespace Aleph
116 # endif // WARSHALL_H
117 
GT * get_list_graph()
Definition: tpl_matgraph.H:1220
Definition: tpl_matgraph.H:1099
Definition: ah-comb.H:35
void warshall_compute_transitive_clausure(GT &g, Bit_Mat_Graph< GT, SA > &mat)
Definition: warshall.H:60
void operator()(GT &g, Bit_Mat_Graph< GT > &mat) const
Definition: warshall.H:109
const size_t & get_num_nodes() const
Retorna el número de nodos del grafo (dimensión de la matriz).
Definition: tpl_matgraph.H:1180
void set_list_graph(GT &g)
Definition: tpl_matgraph.H:1210

Leandro Rabindranath León