Aleph-w  1.9
General library for algorithms and data structures
Dijkstra.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 DIJKSTRA_H
28 # define DIJKSTRA_H
29 
30 # include <ahFunction.H>
31 # include <archeap.H>
32 # include <tpl_find_path.H>
33 # include <tpl_agraph.H>
34 
35 namespace Aleph {
36 
37  // conversión de cookie a Node_Info
38 # define DNassert(p) ((Node_Info*) NODE_COOKIE((p)))
39 
40  // Acceso al nodo del árbol en el grafo
41 # define TREENODE(p) (((Tree_Node_Info*)DNassert(p))->tree_node)
42 
43 # define ACC(p) (DNassert(p)->dist) // Acceso a la distancia acumulada
44 # define HEAPNODE(p) (DNassert(p)->heap_node)
45 # define PARENT(p) (DNassert(p)->ret_node)
46 
47 # define DAassert(p) ((Arc_Info*) ARC_COOKIE(p))
48 # define ARC_DIST(p) (Distance () (p))
49 # define TREEARC(p) (((Tree_Arc_Info*)DAassert(p))->tree_arc)
50 # define POT(p) (DAassert(p)->pot)
51 # define GRAPHNODE(p) (static_cast<typename GT::Node*>(NODE_COOKIE(p)))
52 
53 
54 
82  template <class GT,
83  class Distance = Dft_Dist<GT>,
84  template <typename, class> class Itor = Node_Arc_Iterator,
85  class SA = Dft_Show_Arc<GT>>
87 {
88  // Aunque fundamentalmente el algoritmo es el mismo, hay dos enfoques
89  // para calcular el camino mínimo. El primero es pintar el árbol
90  // abarcador de todos los caminos mínimos a partir de un nodo
91  // start. Por pintar se entiende que la solución se encuentra dentro
92  // del mismo grafo y que se distingue mediante marcas.
93  //
94  // El otro enfoque consiste en construir un árbol abarcador separado.
95  //
96  // Según un enfoque u otro, el grafo se inicializa con información
97  // distinta. Así, las clases que comiencen con el prefijo "Tree" son
98  // clases que atañen a la solucipon que construye un árbol abarcador
99  // separado.
100 
101  // Información a colocar en el arco para la versión que pinta
102  struct Arc_Info
103  {
104  typename Distance::Distance_Type pot; // potencial del arco
105  };
106 
107  // Información a colocar en el arco para la versión que construye árbol
108  struct Tree_Arc_Info : public Arc_Info
109  {
110  typename GT::Arc * tree_arc; // imagen en árbol
111  typename Distance::Distance_Type pot; // potencial del arco
112  };
113 
114  // Wrapper de acceso a la distancia (mediante la clase parámetro Distance)
115  struct Get_Potential_Arc : public Distance
116  {
117  Get_Potential_Arc() noexcept { /* empty */ }
118 
119  Get_Potential_Arc(Distance & d) noexcept : Distance(d) { /* empty */ }
120 
121  typename Distance::Distance_Type
122  operator () (typename GT::Arc *a) const noexcept
123  {
124  auto arc_info = (Arc_Info*) ARC_COOKIE(a);
125  return arc_info->pot;
126  }
127  };
128 
129  // Información a colocar en el nodo para la versión que pinta
130  struct Node_Info
131  {
132  typename Distance::Distance_Type dist = 0; // distancia acumulada
133  void * heap_node = nullptr;
134  void * ret_node = nullptr; // padre en árbol
135  };
136 
137  // Información a colocar en el nodo para la versión que construye árbol
138  struct Tree_Node_Info : public Node_Info
139  {
140  typename GT::Node * tree_node = nullptr; // nodo árbol abarcador
141  typename Distance::Distance_Type dist; // distancia acumulada
142  void * heap_node = nullptr;
143  };
144 
145  // Acceso al heap de arcos
146  struct Dijkstra_Heap_Info
147  {
148  typedef typename
149  ArcHeap<GT, Get_Potential_Arc, Dijkstra_Heap_Info>::Node Node;
150 
151  Node *& operator () (typename GT::Node * p) const noexcept
152  {
153  return (Node*&) HEAPNODE(p);
154  }
155  };
156 
157  // Inicialización de nodo para la versión que pinta
158  struct Initialize_Node
159  {
160  void operator () (const GT & g, typename GT::Node * p) const noexcept
161  {
162  g.reset_bit(p, Aleph::Spanning_Tree);
163  NODE_COOKIE(p) = new Node_Info;
164  }
165  };
166 
167  // Liberación de memoria de nodo para la versión que pinta
168  struct Destroy_Node
169  {
170  void operator () (const GT &, typename GT::Node * p) const noexcept
171  {
172  void * tmp = PARENT(p);
173  delete DNassert(p); //bloque a liberar
174  NODE_COOKIE(p) = tmp;
175  }
176  };
177 
178  // Inicialización de arco para la versión que pinta
179  struct Initialize_Arc
180  {
181  void operator () (const GT & g, typename GT::Arc * a) const noexcept
182  {
183  g.reset_bit(a, Aleph::Spanning_Tree);
184  ARC_COOKIE(a) = new Arc_Info;
185  POT(a) = 0;
186  }
187  };
188 
189  // Liberación de memoria de arco para la versión que pinta
190  struct Destroy_Arc
191  {
192  void operator () (const GT &, typename GT::Arc * ga) const noexcept
193  {
194  delete DAassert(ga);
195  }
196  };
197 
198  // Inicialización de memoria de nodo para la versión que construye árbol
199  struct Initialize_Tree_Node
200  {
201  void operator () (const GT & g, typename GT::Node * p) const noexcept
202  {
203  g.reset_bit(p, Aleph::Spanning_Tree);
204  NODE_COOKIE(p) = new Tree_Node_Info;
205  }
206  };
207 
208  // Liberación de memoria de nodo y mapeo para versión que construye árbol
209  struct Destroy_Tree_Node
210  {
211  void operator () (const GT &, typename GT::Node * p) const noexcept
212  {
213  auto aux = (Tree_Node_Info *) DNassert(p); //bloque a liberar
214  auto tp = TREENODE(p); // imagen en árbol abarcador
215  if (tp != nullptr) // ¿está este nodo incluído en el árbol abarcador?
216  {
217  NODE_COOKIE(p) = NODE_COOKIE(tp) = nullptr;
218  GT::map_nodes (p, tp);
219  }
220  else
221  NODE_COOKIE(p) = nullptr;
222 
223  delete aux;
224  }
225  };
226 
227  // Inicialización de arco para la versión que construye árbol
228  struct Initialize_Tree_Arc
229  {
230  void operator () (const GT & g, typename GT::Arc * a) const noexcept
231  {
232  g.reset_bit(a, Aleph::Spanning_Tree);
233  ARC_COOKIE(a) = new Tree_Arc_Info;
234  POT(a) = 0;
235  TREEARC(a) = nullptr;
236  }
237  };
238 
239  // Liberación de memoria y mapeo para la versión que construye árbol
240  struct Destroy_Tree_Arc
241  {
242  void operator () (const GT &, typename GT::Arc * ga) const noexcept
243  {
244  auto aux = (Tree_Arc_Info *) DAassert(ga);
245  typename GT::Arc * ta = TREEARC(ga);
246  if (ta != nullptr) // ¿pertenece este arco al árbol abarcador?
247  {
248  assert(IS_ARC_VISITED(ga, Aleph::Spanning_Tree));
249  GT::map_arcs (ga, ta); // sí ==> mapearlo
250  }
251 
252  delete aux;
253  }
254  };
255 
256  typedef Dijkstra_Heap_Info Heap_Info;
257 
258  typedef ArcHeap<GT, Get_Potential_Arc, Heap_Info> Heap;
259 
260  SA sa;
261  Get_Potential_Arc get_pot;
262  Heap heap;
263  bool painted = false;
264  GT * ptr_g = nullptr;
265  typename GT::Node * s = nullptr;
266 
267 public:
268 
269  // Constructores
270 
277  Dijkstra_Min_Paths(Distance dist = Distance(),
278  SA __sa = SA())
279  noexcept(std::is_nothrow_move_assignable<SA>::value)
280  : sa(__sa), get_pot(dist), heap(get_pot, Heap_Info()),
281  painted(false), ptr_g(nullptr), s(nullptr)
282  {
283  // empty
284  }
285 
286 private:
287 
288  template <class IN, class IA>
289  void init(const GT & g, typename GT::Node * start)
290  {
291  heap.empty();
292 
293  ptr_g = &const_cast<GT&>(g);
294  s = start;
295 
297 
298  (Operate_On_Arcs <GT, IA> (sa)) (g);
299  }
300 
301  template <class DN, class DA>
302  void uninit()
303  {
304  Operate_On_Nodes <GT, DN> () (*ptr_g);
305 
306  (Operate_On_Arcs <GT, DA, SA> (sa)) (*ptr_g);
307  }
308 
309 public:
310 
320  typename GT::Node *
321  compute_min_paths_tree(const GT & g, typename GT::Node * start, GT & tree)
322  {
323  init<Initialize_Tree_Node, Initialize_Tree_Arc>(g, start);
324 
325  clear_graph(tree); // limpiar árbol abarcador destino
326 
327  NODE_BITS(start).set_bit(Aleph::Spanning_Tree, true);
328  ACC(start) = 0;
329  auto ret = TREENODE(start) = tree.insert_node(start->get_info());
330  NODE_COOKIE(TREENODE(start)) = start;
331 
332  for (Itor<GT, SA> it(start, sa); it.has_curr(); it.next_ne())
333  {
334  auto arc = it.get_current_arc_ne();
335  POT(arc) = ARC_DIST(arc);
336  heap.put_arc(arc, it.get_tgt_node());
337  }
338 
339  const auto & n = g.get_num_nodes();
340 
341  while (tree.get_num_nodes() < n) // mientras tree no abarque a g
342  {
343  auto garc = heap.get_min_arc();
344  if (IS_ARC_VISITED(garc, Aleph::Spanning_Tree))
345  continue;
346 
347  auto gsrc = g.get_src_node(garc);
348  auto gtgt = g.get_tgt_node(garc);
349 
350  // ¿Están los dos nodos visitados?
351  if (IS_NODE_VISITED(gsrc, Aleph::Spanning_Tree) and
352  IS_NODE_VISITED(gtgt, Aleph::Spanning_Tree))
353  continue; // insertar arco causaría ciclo
354 
355  ARC_BITS(garc).set_bit(Aleph::Spanning_Tree, true);
356 
357  if (IS_NODE_VISITED(gtgt, Aleph::Spanning_Tree))
358  std::swap(gsrc, gtgt);
359 
360  NODE_BITS(gtgt).set_bit(Aleph::Spanning_Tree, true);
361 
362  auto ttgt = tree.insert_node(gtgt->get_info());
363  TREENODE(gtgt) = ttgt;
364  auto tsrc = TREENODE(gsrc);
365 
366  auto tarc = tree.insert_arc(tsrc, ttgt, garc->get_info());
367  TREEARC(garc) = tarc;
368 
369  ACC(gtgt) = ACC(gsrc) + ARC_DIST(garc); // total dist nodo inicial
370  const auto & acc = ACC(gtgt);
371 
372  // por cada arco calcular potencial e insertarlo en heap
373  for (Itor<GT, SA> it(gtgt, sa); it.has_curr(); it.next_ne())
374  {
375  auto arc = it.get_current_arc_ne();
376  if (IS_ARC_VISITED(arc, Aleph::Spanning_Tree))
377  continue;
378 
379  auto tgt = it.get_tgt_node();
380  if (IS_NODE_VISITED(tgt, Aleph::Spanning_Tree))
381  continue; // causaría ciclo ==> no se mete en heap
382 
383  POT(arc) = acc + ARC_DIST(arc); // calcula potencial
384  heap.put_arc(arc, tgt);
385  }
386  }
387 
388  uninit<Destroy_Tree_Node, Destroy_Tree_Arc> ();
389 
390  return ret;
391  }
392 
407  void compute_partial_min_paths_tree(const GT & g,
408  typename GT::Node * start,
409  typename GT::Node * end,
410  GT & tree)
411  {
412  init <Initialize_Tree_Node, Initialize_Tree_Arc> (g, start);
413  clear_graph(tree);
414 
415  NODE_BITS(start).set_bit(Aleph::Spanning_Tree, true);
416  ACC(start) = 0;
417  TREENODE(start) = tree.insert_node(start->get_info());
418  NODE_COOKIE(TREENODE(start)) = start;
419 
420  for (Itor<GT, SA> it(start, sa); it.has_curr(); it.next_ne())
421  {
422  auto arc = it.get_current_arc_ne();
423  POT(arc) = ARC_DIST(arc);
424  heap.put_arc(arc, it.get_tgt_node());
425  }
426 
427  const auto & n = g.get_num_nodes();
428 
429  while (tree.get_num_nodes() < n and not heap.is_empty()) // tree no abarque
430  {
431  auto garc = heap.get_min_arc();
432  if (IS_ARC_VISITED(garc, Aleph::Spanning_Tree))
433  continue;
434 
435  auto gsrc = g.get_src_node(garc);
436  auto gtgt = g.get_tgt_node(garc);
437 
438  // ¿Están los dos nodos visitados?
439  if (IS_NODE_VISITED(gsrc, Aleph::Spanning_Tree) and
440  IS_NODE_VISITED(gtgt, Aleph::Spanning_Tree))
441  continue; // insertar arco causaría ciclo
442 
443  ARC_BITS(garc).set_bit(Aleph::Spanning_Tree, true);
444 
445  if (IS_NODE_VISITED(gtgt, Aleph::Spanning_Tree))
446  std::swap(gsrc, gtgt);
447 
448  auto ttgt = tree.insert_node(gtgt->get_info());
449  TREENODE(gtgt) = ttgt;
450  NODE_BITS(gtgt).set_bit(Aleph::Spanning_Tree, true);
451 
452  auto tarc = // insertar nuevo arco en tree
453  tree.insert_arc(TREENODE(gsrc), TREENODE(gtgt), garc->get_info());
454  TREEARC(garc) = tarc;
455 
456  if (gtgt == end) // ¿está end_node en árbol abarcador?
457  break; // sí ==> camino mínimo ya está en árbol abarcador
458 
459  ACC(gtgt) = ACC(gsrc) + ARC_DIST(garc); // total dist nodo inicial
460  const auto & acc = ACC(gtgt);
461 
462  // por cada arco calcular potencial e insertarlo en heap
463  for (Itor<GT, SA> it(gtgt, sa); it.has_curr(); it.next_ne())
464  {
465  auto arc = it.get_current_arc_ne();
466  if (IS_ARC_VISITED(arc, Aleph::Spanning_Tree))
467  continue;
468 
469  auto tgt = it.get_tgt_node();
470  if (IS_NODE_VISITED(tgt, Aleph::Spanning_Tree))
471  continue; // causaría ciclo ==> no se mete en heap
472 
473  POT(arc) = acc + ARC_DIST(arc); // calcula potencial
474  heap.put_arc(arc, tgt);
475  }
476  }
477 
478  uninit <Destroy_Tree_Node, Destroy_Tree_Arc> ();
479  }
480 
490  bool paint_partial_min_paths_tree(const GT & g,
491  typename GT::Node * start,
492  typename GT::Node * end)
493  {
494  bool ret_val = false;
495  init<Initialize_Node, Initialize_Arc> (g, start);
496 
497  NODE_BITS(start).set_bit(Aleph::Spanning_Tree, true);
498  ACC(start) = 0;
499 
500  for (Itor<GT, SA> it(start, sa); it.has_curr(); it.next_ne())
501  {
502  auto arc = it.get_current_arc_ne();
503  POT(arc) = ARC_DIST(arc);
504  heap.put_arc(arc, it.get_tgt_node());
505  }
506 
507  const auto & n = g.get_num_nodes();
508  size_t tn = 1; // número de nodos pintados
509 
510  while (tn < n and not heap.is_empty()) // tree no abarque g
511  {
512  auto garc = heap.get_min_arc();
513  if (IS_ARC_VISITED(garc, Aleph::Spanning_Tree))
514  continue;
515 
516  auto src = g.get_src_node(garc);
517  auto tgt = g.get_tgt_node(garc);
518 
519  // ¿Están los dos nodos visitados?
520  if (IS_NODE_VISITED(src, Aleph::Spanning_Tree) and
521  IS_NODE_VISITED(tgt, Aleph::Spanning_Tree))
522  continue; // este arco causaría un ciclo
523 
524  ARC_BITS(garc).set_bit(Aleph::Spanning_Tree, true);
525 
526  if (IS_NODE_VISITED(tgt, Aleph::Spanning_Tree))
527  std::swap(src, tgt);
528 
529  NODE_BITS(tgt).set_bit(Aleph::Spanning_Tree, true);
530  PARENT(tgt) = src;
531 
532  ++tn; // simula que p se metió en el árbol abarcador
533 
534  if (tgt == end) // ¿está end_node en árbol abarcador?
535  {
536  ret_val = true;
537  break; // sí ==> camino mínimo ya está pintado
538  }
539 
540  ACC(tgt) = ACC(src) + ARC_DIST(garc); // total dist nodo inicial
541 
542  const auto & acc = ACC(tgt);
543 
544  // por cada arco calcular potencial e insertarlo en heap
545  for (Itor<GT, SA> it(tgt, sa); it.has_curr(); it.next_ne())
546  {
547  auto a = it.get_current_arc_ne();
548  if (IS_ARC_VISITED(a, Aleph::Spanning_Tree))
549  continue;
550 
551  auto t = it.get_tgt_node();
552  if (IS_NODE_VISITED(t, Aleph::Spanning_Tree))
553  continue; // causaría ciclo ==> no se mete en heap
554 
555  POT(a) = acc + ARC_DIST(a); // calcula potencial
556  heap.put_arc(a, t);
557  }
558  }
559 
560  uninit<Destroy_Node, Destroy_Arc> ();
561  painted = true;
562 
563  return ret_val;
564  }
565 
573  void paint_min_paths_tree(const GT & g, typename GT::Node * start)
574  {
575  init<Initialize_Node, Initialize_Arc> (g, start);
576 
577  NODE_BITS(start).set_bit(Aleph::Spanning_Tree, true);
578  ACC(start) = 0;
579 
580  for (Itor<GT, SA> it(start, sa); it.has_curr(); it.next_ne())
581  {
582  auto arc = it.get_current_arc_ne();
583  POT(arc) = ARC_DIST(arc);
584  heap.put_arc(arc, it.get_tgt_node());
585  }
586 
587  const auto & n = g.get_num_nodes();
588  size_t tn = 1; // número de nodos pintados
589 
590  while (tn < n and not heap.is_empty()) // tree no abarque g
591  {
592  auto garc = heap.get_min_arc();
593  if (IS_ARC_VISITED(garc, Aleph::Spanning_Tree))
594  continue;
595 
596  auto src = g.get_src_node(garc);
597  auto tgt = g.get_tgt_node(garc);
598 
599  // ¿Están los dos nodos visitados?
600  if (IS_NODE_VISITED(src, Aleph::Spanning_Tree) and
601  IS_NODE_VISITED(tgt, Aleph::Spanning_Tree))
602  continue; // este arco causaría un ciclo
603 
604  ARC_BITS(garc).set_bit(Aleph::Spanning_Tree, true);
605 
606  if (IS_NODE_VISITED(tgt, Aleph::Spanning_Tree))
607  std::swap(src, tgt);
608 
609  NODE_BITS(tgt).set_bit(Aleph::Spanning_Tree, true);
610  PARENT(tgt) = src;
611 
612  ++tn; // simula que p se metió en el árbol abarcador
613 
614  ACC(tgt) = ACC(src) + ARC_DIST(garc); // total dist nodo inicial
615  const auto & acc = ACC(tgt);
616 
617  // por cada arco calcular potencial e insertarlo en heap
618  for (Itor<GT, SA> it(tgt, sa); it.has_curr(); it.next_ne())
619  {
620  auto a = it.get_current_arc_ne();
621  if (IS_ARC_VISITED(a, Aleph::Spanning_Tree))
622  continue;
623 
624  auto t = it.get_tgt_node();
625  if (IS_NODE_VISITED(t, Aleph::Spanning_Tree))
626  continue; // causaría ciclo ==> no se mete en heap
627 
628  POT(a) = acc + ARC_DIST(a); // calcula potencial
629  heap.put_arc(a, t);
630  }
631  }
632 
633  uninit<Destroy_Node, Destroy_Arc> ();
634  painted = true;
635  }
636 
659  typename Distance::Distance_Type
660  get_min_path(typename GT::Node * end, Path<GT> & path)
661  {
662  if (ptr_g == nullptr)
663  throw std::domain_error("Min path has not been computed");
664 
665  if (not painted)
666  throw std::domain_error("Graph has not previously painted");
667 
668  return Aleph::get_min_path<GT, Distance>(s, end, path);
669  }
670 
689  typename Distance::Distance_Type
690  find_min_path(const GT & g,
691  typename GT::Node * start, typename GT::Node * end,
692  Path<GT> & min_path)
693  {
694  min_path.empty();
695  if (paint_partial_min_paths_tree(g, start, end))
696  return get_min_path(end, min_path);
697 
698  return numeric_limits<typename Distance::Distance_Type>::max();
699  }
700 
722  void operator () (const GT & g, typename GT::Node * s, GT & tree)
723  {
724  compute_min_paths_tree(g, s, tree);
725  }
726 
740  typename Distance::Distance_Type
741  copy_painted_min_paths_tree(const GT & g, GT & tree)
742  {
743  if (not painted)
744  throw std::domain_error("Graph has not previously painted");
745 
746  using Paint_Filt = Painted_Min_Spanning_Tree<GT, Distance>;
747  Paint_Filt painted;
748  (Copy_Graph<GT, Dft_Show_Node<GT>, Paint_Filt> (painted)) (tree, g);
749 
750  return painted.dist;
751  }
752 
754  typename Distance::Distance_Type operator () (const GT & g,
755  typename GT::Node * s,
756  typename GT::Node * e,
757  Path<GT> & path)
758  {
759  return find_min_path (g, s, e, path);
760  }
761 
763  struct Total
764  {
765  typename Distance::Distance_Type dist;
766 
767  Total() noexcept : dist(0) { /* empty */ }
768 
769  bool operator () (typename GT::Arc * a) noexcept
770  {
771  dist += ARC_DIST(a);
772  return true;
773  }
774  };
775 
797  typename Distance::Distance_Type
798  get_min_path(const GT & tree, typename GT::Node * end, Path<GT> & path)
799  {
800  if (ptr_g == nullptr)
801  throw std::domain_error("Min path has not been computed");
802 
803  auto ts = mapped_node<GT>(s);
804  auto te = mapped_node<GT>(end);
805 
806  Path<GT> tree_path(tree);
807  Total total;
808  (Find_Path_Depth_First<GT, Itor, Total> (total)) (tree, ts, te, tree_path);
809 
810  path.empty();
811  path.init(s);
812  typename Path<GT>::Iterator it(tree_path);
813  for (it.next(); it.has_curr(); it.next_ne())
814  path.append(mapped_node<GT>(it.get_current_node_ne()));
815 
816  return total.dist;
817  }
818 };
819 
820 
821 
822 # undef DNI
823 # undef PARENT
824 # undef TREENODE
825 # undef ACC
826 # undef HEAPNODE
827 # undef DAI
828 # undef ARC_DIST
829 # undef TREEARC
830 # undef POT
831 # undef GRAPHNODE
832 } // end namespace Aleph
833 # endif // DIJKSTRA_H
Definition: tpl_graph.H:3633
void clear_graph(GT &g) noexcept
Definition: tpl_graph.H:3463
#define NODE_COOKIE(p)
Definition: aleph-graph.H:333
Distance::Distance_Type get_min_path(typename GT::Node *end, Path< GT > &path)
Definition: Dijkstra.H:660
Distance::Distance_Type copy_painted_min_paths_tree(const GT &g, GT &tree)
Definition: Dijkstra.H:741
Definition: tpl_graph.H:2493
void compute_partial_min_paths_tree(const GT &g, typename GT::Node *start, typename GT::Node *end, GT &tree)
Definition: Dijkstra.H:407
void paint_min_paths_tree(const GT &g, typename GT::Node *start)
Definition: Dijkstra.H:573
#define IS_NODE_VISITED(p, bit)
Definition: aleph-graph.H:327
GT::Node * compute_min_paths_tree(const GT &g, typename GT::Node *start, GT &tree)
Definition: Dijkstra.H:321
Spanning tree calculation of all shortest paths from a given node according to Dijkstra&#39;s algorithm...
Definition: Dijkstra.H:86
#define ARC_COOKIE(p)
Definition: aleph-graph.H:366
Distance::Distance_Type find_min_path(const GT &g, typename GT::Node *start, typename GT::Node *end, Path< GT > &min_path)
Definition: Dijkstra.H:690
void map_arcs(typename GTS::Arc *p, typename GTT::Arc *q) noexcept
Definition: tpl_graph.H:3445
#define IS_ARC_VISITED(p, bit)
Definition: aleph-graph.H:360
Definition: tpl_graph.H:53
void map_nodes(typename GTS::Node *p, typename GTT::Node *q) noexcept
Definition: tpl_graph.H:3419
Definition: tpl_find_path.H:69
Definition: ah-comb.H:35
Distance::Distance_Type get_min_path(const GT &tree, typename GT::Node *end, Path< GT > &path)
Definition: Dijkstra.H:798
Definition: tpl_graph.H:1063
void next_ne() noexcept
Definition: tpl_dynDlist.H:433
Definition: tpl_graph.H:3723
#define NODE_BITS(p)
Definition: aleph-graph.H:305
bool paint_partial_min_paths_tree(const GT &g, typename GT::Node *start, typename GT::Node *end)
Definition: Dijkstra.H:490
Definition: tpl_graph_utils.H:1753
void next()
Definition: tpl_dynDlist.H:441
void init(Node *start_node)
Definition: tpl_graph.H:2722
void operator()(const GT &g, typename GT::Node *s, GT &tree)
Definition: Dijkstra.H:722
#define ARC_BITS(p)
Definition: aleph-graph.H:351
Clase totalizadora de distancias.
Definition: Dijkstra.H:763
Dijkstra_Min_Paths(Distance dist=Distance(), SA __sa=SA()) noexcept(std::is_nothrow_move_assignable< SA >::value)
Definition: Dijkstra.H:277
void empty()
Clean the path: all the nodes and arc are removed.
Definition: tpl_graph.H:2761
void append(Arc *arc)
Definition: tpl_graph.H:2808
Definition: tpl_graph.H:1177
Distance::Distance_Type dist
Accumutive distance from the first seen arc until the last seen.
Definition: tpl_graph.H:3726
Definition: tpl_graph.H:3135
Definition: tpl_graph.H:2540

Leandro Rabindranath León