Aleph-w  1.9
General library for algorithms and data structures
tpl_matgraph.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_MAT_GRAPH_H
28 # define TPL_MAT_GRAPH_H
29 
30 # include <tpl_graph.H>
31 # include <tpl_sort_utils.H>
32 
33 using namespace Aleph;
34 
35 namespace Aleph
36 {
37 
38  template <typename GT> inline static
39 typename GT::Node * get_node(DynArray<typename GT::Node *> & nodes,
40  const long & i)
41 {
42  if (i >= nodes.size())
43  throw std::out_of_range("Index of node out of range");
44 
45  return nodes.access(i);
46 }
47 
48  template <typename GT> inline static long
49 node_index(DynArray<typename GT::Node *> & nodes,
50  const long & n, typename GT::Node * p)
51 {
52  return Aleph::binary_search(nodes, p, 0, n - 1);
53 }
54 
55  inline static long
56 index_array(const long & i, const long & j, const long & n)
57 {
58  if (i >= n or j >= n)
59  throw std::out_of_range("Matrix index out of range");
60 
61  return i + j*n;
62 }
63 
64  template <typename Entry>
65 inline static Entry * read_matrix(const DynArray<Entry> & mat,
66  const long & i, const long & j,
67  const long & n)
68 {
69  const long index = index_array(i, j, n);
70  if (not mat.exist(index))
71  return nullptr;
72 
73  return &const_cast<Entry&>(mat.access(index));
74 }
75 
76  template <typename Entry>
77 inline static void write_matrix(DynArray<Entry> & mat,
78  const long & i,
79  const long & j,
80  const long & n,
81  const Entry & entry)
82 {
83  mat[index_array(i, j, n)] = entry;
84 }
85 
135  template <class GT, class SA = Dft_Show_Arc<GT> >
137 {
138 public:
140  typedef GT Graph_Type;
141 
143  typedef typename GT::Node_Type Node_Type;
144 
146  typedef typename GT::Arc_Type Arc_Type;
147 
149  typedef typename GT::Node Node;
150 
152  typedef typename GT::Arc Arc;
153 
154 private:
155 
156  DynArray<Node*> nodes;
157  GT * lgraph;
158  mutable size_t num_nodes;
159  SA & sa;
160 
161  struct Mat_Entry
162  {
163  Arc * arc;
164  Mat_Entry(Arc * __arc = nullptr) : arc(__arc) { /* empty */ }
165  };
166 
168 
169 public:
170 
173  inline void copy_list_graph(GT & g);
174 
176  Map_Matrix_Graph(GT & g, SA && __sa = SA())
177  : lgraph(&g), num_nodes(g.get_num_nodes()), sa(__sa)
178  {
179  copy_list_graph(g);
180  }
181 
182  Map_Matrix_Graph(GT & g, SA & __sa)
183  : lgraph(&g), num_nodes(g.get_num_nodes()), sa(__sa)
184  {
185  copy_list_graph(g);
186  }
187 
190  {
191  copy_list_graph(*(mat.lgraph));
192  }
193 
196 
206  inline Map_Matrix_Graph & operator = (GT & g);
207 
220  inline Node * operator () (const long & i);
221 
237  inline long operator () (Node * node) const;
238 
258  inline Arc * operator () (Node * src_node, Node * tgt_node) const;
259 
275  inline Arc * operator () (const long & i, const long & j) const;
276 
278  GT & get_list_graph() { return *lgraph; }
279 
282  const size_t & get_num_nodes() const { return num_nodes; }
283 };
284 
285 
286  template <class GT, class SA> typename GT::Node *
288 {
289  return get_node <GT> (nodes, i);
290 }
291 
292  template <class GT, class SA> long
293 Map_Matrix_Graph<GT, SA>::operator () (typename GT::Node * node) const
294 {
295  return node_index <GT> (nodes, num_nodes, node);
296 }
297 
298  template <class GT, class SA> typename GT::Arc *
299 Map_Matrix_Graph<GT, SA>::operator () (const long & i, const long & j) const
300 {
301  Mat_Entry * mat_entry = read_matrix<Mat_Entry>(mat, i, j, num_nodes);
302  if (mat_entry == nullptr)
303  return nullptr;
304 
305  return mat_entry->arc;
306 }
307 
308  template <class GT, class SA> typename GT::Arc *
309 Map_Matrix_Graph<GT, SA>::operator () (Node * src_node, Node * tgt_node) const
310 {
311  Mat_Entry * mat_entry =
312  read_matrix<Mat_Entry>(mat, node_index<GT>(nodes, num_nodes, src_node),
313  node_index<GT>(nodes, num_nodes, tgt_node),
314  num_nodes);
315  if (mat_entry == nullptr)
316  return nullptr;
317 
318  return mat_entry->arc;
319 }
320 
321  template <class GT, class SA> Map_Matrix_Graph<GT, SA> &
323 {
324  if (this == &mat)
325  return *this;
326 
327  copy_list_graph(*(mat.lgraph));
328  return *this;
329 }
330 
331  template <class GT, class SA>
333 {
334  copy_list_graph(g);
335 }
336 
337  template <class GT, class SA>
339 {
340  // copiar atributos
341  lgraph = &g;
342  num_nodes = g.get_num_nodes();
343  nodes.cut(); // limpiar arreglos dinámicos de contenidos anteriores
344  mat.cut();
345  int i = 0;
346  for (typename GT::Node_Iterator it(g); it.has_curr(); it.next_ne(), ++i)
347  nodes[i] = it.get_current_node_ne();
348 
349  quicksort(nodes); // ordenar nodes para soportar búsqueda binaria
350  for (typename GT::Node_Iterator nit(g); nit.has_curr(); nit.next_ne())
351  {
352  Node * src = nit.get_current_node_ne();
353  const long src_idx = node_index<GT>(nodes, num_nodes, src);
354 
355  // para cada arco de src escribirlo en la matriz mat
356  for (Node_Arc_Iterator<GT, SA> ait(src, sa); ait.has_curr(); ait.next_ne())
357  {
358  Arc * arc = ait.get_current_arc_ne();
359  Node * tgt = g.get_connected_node(arc, src);
360  const long tgt_idx = node_index<GT>(nodes, num_nodes, tgt);
361  write_matrix<Mat_Entry>(mat, src_idx, tgt_idx, num_nodes, arc);
362  }
363  }
364 }
365 
395  template <typename GT, class SA = Dft_Show_Arc<GT> >
397 {
398 public:
399 
401  typedef GT Graph_Type;
402 
405  typedef typename GT::Node_Type Node_Type;
406 
409  typedef typename GT::Arc_Type Arc_Type;
410 
412  typedef typename GT::Node Node;
413 
415  typedef typename GT::Arc Arc;
416 
417 private:
418 
419  DynArray<Node_Type> nodes;
421  mutable size_t n;
422  mutable Arc_Type Null_Value;
423  SA & sa;
424 
425  void copy(Matrix_Graph & mat)
426  {
427  if (this == &mat)
428  return;
429 
430  n = mat.n; // copiar atributos
431  Null_Value = mat.Null_value;
432  nodes.cut(); // limpiar memoria de arreglos dinámicos
433  arcs.cut();
434  arcs.set_default_initial_value(Null_Value);
435 
436  // recorrer mat[i,j] y copiarla a nodes[], arcs[]
437  for (int i = 0; i < n; ++i)
438  {
439  nodes[i] = mat.nodes[i];
440  for (int j = 0; j < n; ++j)
441  {
442  const long mat_index = index_array(i, j, n);
443  if (not arcs.exist(mat_index))
444  continue;
445  arcs.touch(mat_index) = mat.arcs.access(mat_index);
446  }
447  }
448  }
449 
450  void copy(GT & g)
451  {
452  n = g.get_num_nodes();
453  DynArray<typename GT::Node *> ptr; // arreglo temporal
454 
455  int i = 0;
456  for (typename GT::Node_Iterator it(g); it.has_curr(); it.next_ne(), ++i)
457  ptr[i] = it.get_current_node_ne();
458 
459  quicksort(ptr); // ordenar por si se relaciona con Map_Matrix_Graph
460 
461  arcs.set_default_initial_value(Null_Value);
462 
463  for (i = 0; i < n; ++i) // coloca contenidos de ptr[] en nodes[]
464  {
465  typename GT::Node * src = ptr[i];
466  nodes[i] = src->get_info();
467  for (Node_Arc_Iterator<GT, SA> it(src); it.has_curr(); it.next_ne())
468  {
469  typename GT::Arc * arc = it.get_current_arc_ne();
470  typename GT::Node * tgt = it.get_tgt_node();
471  const long j = node_index<GT>(ptr, n, tgt);
472  const long mat_index = index_array(i, j, n);
473  arcs[mat_index] = arc->get_info();
474  }
475  }
476  }
477 
478 public:
479 
481  const size_t & get_num_nodes() const { return n; }
482 
484  const Arc_Type & null_value() const { return Null_Value; }
485 
503  Matrix_Graph(GT & g, const Arc_Type & null, SA && __sa = SA())
504  : Null_Value(null), sa(__sa)
505  {
506  copy(g);
507  }
508 
509  Matrix_Graph(GT & g, const Arc_Type & null, SA & __sa)
510  : Null_Value(null), sa(__sa)
511  {
512  copy(g);
513  }
514 
524  {
525  copy(mat);
526  }
527 
541  {
542  copy(mat);
543  return *this;
544  }
545 
560  {
561  copy(g);
562  return *this;
563  }
564 
581  const Arc_Type & operator () (const long & i, const long & j) const
582  {
583  const long mat_index = index_array(i, j, n);
584  if (not arcs.exist(mat_index)) // ¿Existe entrada?
585  return Null_Value; // No ==> no hay arco
586 
587  return arcs.access(mat_index);
588  }
589 
599  Node_Type & operator () (const long & i) const
600  {
601  if (i >= n)
602  throw std::out_of_range("node index out of range");
603 
604  return const_cast<Node_Type &>(nodes.access(i));
605  }
606 
623  Arc_Type & operator () (const long & i, const long & j)
624  {
625  const long mat_index = index_array(i, j, n);
626 
627  return arcs.touch(mat_index);
628  }
629 };
630 
657  template <class GT, typename __Entry_Type, class SA = Dft_Show_Arc<GT> >
658 class Ady_Mat
659 {
660 public:
661 
663  typedef GT Graph_Type;
664 
666  typedef __Entry_Type Entry_Type;
667 
670  typedef typename GT::Node_Type Node_Type;
671 
674  typedef typename GT::Arc_Type Arc_Type;
675 
677  typedef typename GT::Node Node;
678 
680  typedef typename GT::Arc Arc;
681 
682 private:
683 
684  GT * lgraph;
685  DynArray<Node*> nodes;
687  mutable size_t num_nodes;
688  mutable Entry_Type Null_Value;
689 
690  void test_same_graph(Ady_Mat & mat)
691  {
692  if (lgraph == mat.lgraph)
693  return;
694 
695  throw
696  std::domain_error("mat does not refers the same GT than this");
697  }
698 
699  void copy_nodes(GT & g)
700  {
701  lgraph = &g;
702  num_nodes = g.get_num_nodes();
703  nodes.cut(); // limpiar memoria por los nodos
704 
705  // coloca punteros a nodos en el arreglo nodes[]
706  int i = 0;
707  for (typename GT::Node_Iterator it(g); it.has_curr(); it.next_ne(), ++i)
708  nodes[i] = it.get_current_node_ne();
709 
710  quicksort(nodes); // ordena para luego hacer búsqueda binaria
711  }
712 
713  Ady_Mat & copy(Ady_Mat & mat)
714  {
715  if (this == &mat)
716  return *this;
717 
718  test_same_graph(mat);
719  Null_Value = mat.Null_Value;
720  copy(mat.lgraph);
721 
722  return *this;
723  }
724 
725 public:
726 
729  Node * operator () (const long & i)
730  {
731  return Aleph::get_node<GT>(nodes, i);
732  }
733 
736  long operator () (Node * node) const
737  {
738  return node_index<GT>(nodes, num_nodes, node);
739  }
740 
755  Entry_Type & operator () (const long & i, const long & j)
756  {
757  return mat.touch(index_array(i, j, num_nodes));
758  }
759 
774  const Entry_Type & operator () (const long & i, const long & j) const
775  {
776  const long index = index_array(i, j, num_nodes);
777 
778  if (mat.exist(index))
779  return mat.access(index);
780 
781  return Null_Value;
782  }
783 
801  Entry_Type & operator () (Node * src, Node * tgt)
802  {
803  return (*this)(node_index <GT> (nodes, num_nodes, src),
804  node_index <GT> (nodes, num_nodes, tgt));
805  }
806 
824  const Entry_Type & operator () (Node * src, Node * tgt) const
825  {
826  return (*this)(node_index <GT> (nodes, num_nodes, src),
827  node_index <GT> (nodes, num_nodes, tgt));
828  }
829 
831  GT & get_list_graph() { return *lgraph; }
832 
834  const Entry_Type & null_value() const { return Null_Value; }
835 
838  const size_t & get_num_nodes() const { return num_nodes; }
839 
855  Ady_Mat(GT & g)
856  : lgraph(&g), num_nodes(lgraph->get_num_nodes())
857  {
858  copy_nodes(g);
859  }
860 
875  Ady_Mat(GT & g, const Entry_Type & null)
876  : lgraph(&g), num_nodes(lgraph->get_num_nodes()), Null_Value(null)
877  {
878  copy_nodes(*lgraph);
879  }
880 
882  void set_null_value(const Entry_Type & null) { Null_Value = null; }
883 
885  Ady_Mat(Ady_Mat & mat)
886  {
887  copy(mat);
888  }
889 
913  template <class Operation> void operate_all_arcs_list_graph();
914 
944  template <class Operation> void operate_all_arcs_list_graph(void * ptr);
945 
965  template <class Operation> void operate_all_arcs_matrix();
966 
991  template <class Operation>
992  void operate_all_arcs_matrix(void * ptr);
993 };
994 
995 
996  template <class GT, typename __Entry_Type, class SA>
997  template <class Operation>
999 { // recorrer todos los nodos del grafo
1000  for (typename GT::Node_Iterator nit(*lgraph); nit.has_curr(); nit.next_ne())
1001  {
1002  Node * src = nit.get_current_node_ne();
1003  const long src_idx = node_index<Graph_Type>(nodes, num_nodes, src);
1004 
1005  // recorrer todos los arcos del nodo origen
1006  for (Node_Arc_Iterator<GT, SA> at(src); at.has_curr(); at.next_ne())
1007  {
1008  Arc * arc = at.get_current_arc_ne();
1009  const long tgt_idx =
1010  node_index<Graph_Type>(nodes, num_nodes, arc->get_tgt_node());
1011  Entry_Type & entry =
1012  mat.touch(index_array(src_idx, tgt_idx, num_nodes));
1013 
1014  Operation () (*this, arc, src_idx, tgt_idx, entry);
1015  }
1016  }
1017 }
1018 
1019  template <class GT, typename __Entry_Type, class SA>
1020  template <class Operation>
1022 {
1023  const long & n = num_nodes;
1024  for (int s = 0; s < n; ++s)
1025  {
1026  Node * src_node = get_node<GT>(nodes, s);
1027  for (int t = 0; t < n; ++t)
1028  {
1029  Node * tgt_node = get_node<GT>(nodes, t);
1030  Entry_Type & entry = mat.touch(index_array(s, t, num_nodes));
1031 
1032  Operation () (*this, src_node, tgt_node, s, t, entry);
1033  }
1034  }
1035 }
1036 
1037  template <class GT, typename __Entry_Type, class SA>
1038  template <class Operation>
1040 { // recorrer todos los nodos del grafo
1041  for (typename GT::Node_Iterator nit(*lgraph); nit.has_curr(); nit.next_ne())
1042  {
1043  Node * src = nit.get_current_node_ne();
1044  const long src_idx = node_index<Graph_Type>(nodes, num_nodes, src);
1045 
1046  // recorrer todos los arcos del nodo origen
1047  for (Node_Arc_Iterator<GT, SA> at(src); at.has_curr(); at.next_ne())
1048  {
1049  Arc * arc = at.get_current_arc_ne();
1050  Node * tgt = lgraph->get_tgt_node(arc);
1051  const long tgt_idx = node_index<Graph_Type>(nodes, num_nodes, tgt);
1052  Entry_Type & entry = // asegurar acceso a mat(src_idx, tgt_idx)
1053  mat.touch(index_array(src_idx, tgt_idx, num_nodes));
1054 
1055  Operation () (*this, arc, src_idx, tgt_idx, entry, ptr);
1056  }
1057  }
1058 }
1059 
1060  template <class GT, typename __Entry_Type, class SA>
1061  template <class Operation>
1063 {
1064  const long & n = num_nodes;
1065 
1066  for (int s = 0; s < n; ++s)
1067  {
1068  Node * src_node = get_node<GT>(nodes, s);
1069 
1070  for (int t = 0; t < n; ++t)
1071  {
1072  Node * tgt_node = get_node<GT>(nodes, t);
1073  Entry_Type & entry = mat.touch(index_array(s, t, num_nodes));
1074  Operation () (*this, src_node, tgt_node, s, t, entry, ptr);
1075  }
1076  }
1077 }
1078 
1098  template <class GT, class SA = Dft_Show_Arc<GT> >
1100 {
1101 public:
1102 
1104  typedef GT Graph_Type;
1105 
1107  typedef typename GT::Node Node;
1108 
1110  typedef typename GT::Arc Arc;
1111 
1112 private:
1113 
1114  BitArray bit_array;
1115  GT * lgraph;
1117  mutable size_t n;
1118 
1119  void copy_list_graph(GT & g)
1120  {
1121  n = g.get_num_nodes();
1122  nodes.cut(); // liberar memoria
1123 
1124  // copiar todos los nodos de g al arreglo nodes[]
1125  int i = 0;
1126  for (typename GT::Node_Iterator it(g); it.has_curr(); it.next_ne())
1127  nodes[i++] = static_cast<typename GT::Node*>(it.get_current_node_ne());
1128 
1129  quicksort(nodes); // ordenar para luego hacer búsqueda binaria
1130 
1131  // recorrer todos los nodos de g para asignar los arcos en bit_array
1132  for (typename GT::Node_Iterator it(g); it.has_curr(); it.next_ne())
1133  {
1134  typename GT::Node * src = it.get_current_node_ne();
1135  const size_t src_idx = node_index<Graph_Type>(nodes, n, src);
1136 
1137  // recorrer los arcos de src para asignar entrada en matriz
1138  for (Node_Arc_Iterator<GT, SA> jt(src); jt.has_curr(); jt.next_ne())
1139  {
1140  typename GT::Node * tgt = jt.get_tgt_node_ne();
1141  const size_t tgt_idx = node_index<Graph_Type>(nodes, n, tgt);
1142  bit_array[index_array(src_idx, tgt_idx, n)] = 1;
1143  }
1144  }
1145  }
1146 
1147  struct Proxy
1148  {
1149  BitArray & bit_array;
1150 
1151  const size_t bit_index;
1152 
1153  Proxy(Bit_Mat_Graph & __bitmat, const long & i, const long & j)
1154  : bit_array(__bitmat.bit_array), bit_index(index_array(i, j, __bitmat.n))
1155  {
1156  // empty
1157  }
1158 
1159  Proxy& operator = (const Proxy & proxy)
1160  {
1161  bit_array[bit_index] = proxy.bit_array[proxy.bit_index];
1162  }
1163 
1164  Proxy& operator = (const int & i)
1165  {
1166  bit_array[bit_index] = i;
1167 
1168  return *this;
1169  }
1170 
1171  operator int () const
1172  {
1173  return bit_array[bit_index];
1174  }
1175  };
1176 
1177 public:
1178 
1180  const size_t & get_num_nodes() const { return n; }
1181 
1183  Bit_Mat_Graph() : lgraph(nullptr) {}
1184 
1187  Bit_Mat_Graph(GT & g)
1188  : bit_array(g.get_num_nodes()*g.get_num_nodes()), lgraph(&g)
1189  {
1190  copy_list_graph(g);
1191  }
1192 
1195  : bit_array(bitmat.bit_array), lgraph(bitmat.lgraph),
1196  nodes(bitmat.nodes), n(bitmat.n)
1197  {
1198  // empty
1199  }
1200 
1202  Bit_Mat_Graph(const size_t & dim)
1203  : bit_array(dim*dim), lgraph(nullptr), nodes(dim), n(dim)
1204  {
1205  // empty
1206  }
1207 
1210  void set_list_graph(GT & g)
1211  {
1212  const size_t & n = g.get_num_nodes();
1213  bit_array.set_size(n*n);
1214  lgraph = &g;
1215  copy_list_graph(g);
1216  }
1217 
1220  GT * get_list_graph() { return lgraph; }
1221 
1224  {
1225  if (this == &bitmat)
1226  return *this;
1227 
1228  lgraph = bitmat.lgraph;
1229  bit_array = bitmat.bit_array;
1230 
1231  return *this;
1232  }
1233 
1236  {
1237  if (&g == lgraph)
1238  return *this;
1239 
1240  copy_list_graph(g);
1241 
1242  return *this;
1243  }
1244 
1247  Node * operator () (const long & i)
1248  {
1249  if (lgraph == nullptr)
1250  throw std::domain_error("There is no a GT object");
1251 
1252  return Aleph::get_node<GT>(nodes, i);
1253  }
1256  long operator () (Node * node) const
1257  {
1258  if (lgraph == nullptr)
1259  throw std::domain_error("There is no a GT object");
1260 
1261  return node_index<GT>(nodes, n, node);
1262  }
1263 
1264  Proxy operator () (const long & i, const long & j)
1265  {
1266  return Proxy(*this, i, j);
1267  }
1268 
1269  Proxy operator () (const long & i, const long & j) const
1270  {
1271  return Proxy(const_cast<Bit_Mat_Graph&>(*this), i, j);
1272  }
1273 
1274  Proxy operator () (Node * src_node, Node * tgt_node)
1275  {
1276  if (lgraph == nullptr)
1277  throw std::domain_error("There is no a GT object");
1278 
1279  return Proxy(*this, node_index<GT>(nodes, n, src_node),
1280  node_index<GT>(nodes, n, tgt_node));
1281  }
1282 
1283  Proxy operator () (Node * src_node, Node * tgt_node) const
1284  {
1285  if (lgraph == nullptr)
1286  throw std::domain_error("There is no a GT object");
1287 
1288  return Proxy(*this, node_index<GT>(nodes, n, src_node),
1289  node_index<GT>(nodes, n, tgt_node));
1290  }
1291 };
1292 
1293 } // end namespace Aleph
1294 
1295 # endif // TPL_MAT_GRAPH_H
Matrix_Graph(Matrix_Graph &mat)
Definition: tpl_matgraph.H:523
const Arc_Type & null_value() const
El valor constante que representa la entrada nula en la matriz.
Definition: tpl_matgraph.H:484
GT Graph_Type
El tipo de grafo representado con listas de adyacencia.
Definition: tpl_matgraph.H:663
GT::Arc Arc
El tipo de arco usado en la representación con listas de adyacencia.
Definition: tpl_matgraph.H:680
const size_t & get_num_nodes() const
Definition: tpl_matgraph.H:282
void cut(const size_t new_dim=0)
Definition: tpl_dynArray.H:1104
GT::Node Node
El tipo de nodo que se maneja el objeto GT.
Definition: tpl_matgraph.H:149
GT Graph_Type
El tipo de Graph_List asociado a la matriz.
Definition: tpl_matgraph.H:140
Ady_Mat(GT &g)
Definition: tpl_matgraph.H:855
GT & get_list_graph()
Retorna una referencia al grafo representado con lista de adyacencia.
Definition: tpl_matgraph.H:831
GT * get_list_graph()
Definition: tpl_matgraph.H:1220
Bit_Mat_Graph()
Constructor vacío.
Definition: tpl_matgraph.H:1183
Definition: bitArray.H:135
T & access(const size_t i) const noexcept
Definition: tpl_dynArray.H:874
T & touch(const size_t i)
Definition: tpl_dynArray.H:958
GT::Node Node
El tipo de nodo en GT.
Definition: tpl_matgraph.H:1107
Definition: tpl_matgraph.H:136
void operate_all_arcs_matrix()
Definition: tpl_matgraph.H:1021
Definition: tpl_matgraph.H:396
Bit_Mat_Graph(const Bit_Mat_Graph &bitmat)
Constructor copia.
Definition: tpl_matgraph.H:1194
Map_Matrix_Graph & operator=(Map_Matrix_Graph &mat)
Asignación de matriz de adyacencia.
Definition: tpl_matgraph.H:322
GT::Node_Type Node_Type
Definition: tpl_matgraph.H:670
Ady_Mat(GT &g, const Entry_Type &null)
Definition: tpl_matgraph.H:875
Ady_Mat(Ady_Mat &mat)
Constructor copia.
Definition: tpl_matgraph.H:885
const size_t & get_num_nodes() const
Definition: tpl_matgraph.H:838
bool exist(const size_t i) const
Definition: tpl_dynArray.H:895
GT::Node Node
El tipo de nodo usado en la representación con listas de adyacencia.
Definition: tpl_matgraph.H:677
Definition: tpl_matgraph.H:1099
DynList< typename GT::Arc * > arcs(typename GT::Node *p, SA sa=SA())
Definition: tpl_graph.H:1893
GT::Node Node
El tipo de Graph_Node que usado en el GT.
Definition: tpl_matgraph.H:412
void operate_all_arcs_list_graph()
Definition: tpl_matgraph.H:998
Definition: tpl_matgraph.H:658
GT::Arc_Type Arc_Type
Definition: tpl_matgraph.H:674
Definition: ah-comb.H:35
GT Graph_Type
El tipo de grafo GT.
Definition: tpl_matgraph.H:1104
GT::Node_Type Node_Type
Definition: tpl_matgraph.H:405
GT::Arc_Type Arc_Type
Definition: tpl_matgraph.H:409
void set_size(const size_t sz)
Reajusta la dimensión del arreglo.
Definition: bitArray.H:244
__Entry_Type Entry_Type
El tipo de dato que alberga la matriz.
Definition: tpl_matgraph.H:666
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
size_t size() const noexcept
Definition: tpl_dynArray.H:641
Bit_Mat_Graph(const size_t &dim)
Constructor especificando una dimensión.
Definition: tpl_matgraph.H:1202
Bit_Mat_Graph(GT &g)
Definition: tpl_matgraph.H:1187
Node * operator()(const long &i)
Definition: tpl_matgraph.H:287
Map_Matrix_Graph(GT &g, SA &&__sa=SA())
Constructor a partir de un grafo representado con listas de adyacencia.
Definition: tpl_matgraph.H:176
Definition: tpl_dynArray.H:159
Matrix_Graph(GT &g, const Arc_Type &null, SA &&__sa=SA())
Definition: tpl_matgraph.H:503
void set_default_initial_value(const T &value) noexcept
Definition: tpl_dynArray.H:659
GT Graph_Type
El tipo de grafo representado con listas de adyacencia.
Definition: tpl_matgraph.H:401
GT::Arc_Type Arc_Type
El tipo atributo de arco que guarda los nodos en el objeto GT.
Definition: tpl_matgraph.H:146
void copy_list_graph(GT &g)
Definition: tpl_matgraph.H:338
Definition: tpl_graph.H:1177
GT::Arc Arc
El tipo de arco en GT.
Definition: tpl_matgraph.H:1110
const size_t & get_num_nodes() const
Retorna el número de nodos del grafo (que es la dimensión de la matriz)
Definition: tpl_matgraph.H:481
void set_null_value(const Entry_Type &null)
Declara un valor nulo para la matriz de adyacencia auxiliar.
Definition: tpl_matgraph.H:882
Map_Matrix_Graph(Map_Matrix_Graph &mat)
Constructor copia.
Definition: tpl_matgraph.H:189
void set_list_graph(GT &g)
Definition: tpl_matgraph.H:1210
GT::Arc Arc
El tipo de Graph_Arc que usado en el GT.
Definition: tpl_matgraph.H:415
const Entry_Type & null_value() const
Retorna el valor considerado como nulo.
Definition: tpl_matgraph.H:834
GT::Node_Type Node_Type
El tipo atributo de nodo que guarda los nodos en el objeto GT.
Definition: tpl_matgraph.H:143
GT::Arc Arc
El tipo de arco que se maneja el objeto GT.
Definition: tpl_matgraph.H:152
GT & get_list_graph()
Retorna una referencia al grafo representado con listas enlazadas.
Definition: tpl_matgraph.H:278

Leandro Rabindranath León