85 Via(
char * nom,
int d)
88 Via(
const string& nom,
int d)
122 return p->get_info().nombre == nombre;
127 const string & c1,
const string & c2,
140 string nombre_arco = n1->get_info().nombre +
"--" + n2->get_info().nombre;
151 cout << itor.get_current_node()->get_info().nombre <<
"-";
164 cout <<
INDENT << node_itor.get_current_node()->get_info().nombre << endl;
174 Mapa::Arc * arc = arc_itor.get_current_arc();
175 cout << arc->get_info().nombre <<
" " << arc->get_info().distancia
177 <<
" to " << g.
get_tgt_node(arc)->get_info().nombre << endl;
182 <<
"Graph listing by nodes and for each node by arcs"
187 Mapa::Node * src_node = node_itor.get_current_node();
188 cout << src_node->get_info().nombre << endl;
190 itor.has_curr(); itor.next())
192 Mapa::Arc * arc = itor.get_current_arc();
193 cout <<
INDENT << arc->get_info().distancia <<
" "
203 insert_via(g,
"San Cristobal",
"La Fria", 69);
204 insert_via(g,
"San Cristobal",
"Sacramento", 113);
205 insert_via(g,
"San Cristobal",
"San Antonio", 36);
208 insert_via(g,
"El Vigia",
"Santa Barbara", 59);
219 template <
typename GT>
239 for (
size_t i = 0; i < n; ++i)
258 <<
"buscar_ciudad(tree, \"Merida\") returned nullptr";
260 std::unique_ptr<Tree_Node<string>> t(
265 cout <<
"Enter key to search (type \"quit\"): ";
267 if (not std::getline(std::cin, clave))
271 if (not clave.empty()
and clave.back() ==
'\r')
274 if (clave.empty() or clave ==
"quit")
277 const size_t Buf_Size = 512;
282 search_deway <Tree_Node<string> >(t.get(), clave,
deway, Buf_Size,
286 cout << clave <<
" was not found in the tree" << endl;
289 cout << clave <<
" has Deway number: ";
295 cout <<
"Exiting ... " << endl;
297 ofstream
test(
"prueba.Tree", ios::trunc);
299 <<
"could not open prueba.Tree for writing";
Exception handling system with formatted messages for Aleph-w.
#define ah_runtime_error_if(C)
Throws std::runtime_error if condition holds.
auto has_curr() const noexcept(noexcept(std::declval< I & >().has_curr())) -> decltype(std::declval< I & >().has_curr())
true if there is a current item.
Generic directed graph (digraph) wrapper template.
bool has_curr() const noexcept
Return true if the iterator has current item.
Functor class to convert a tree graph to Tree_Node structure.
Iterator on the arcs of a graph.
Graph implemented with double-linked adjacency lists.
virtual Node * insert_node(Node *node) noexcept
Insertion of a node already allocated.
_Graph_Node Node
The graph type.
_Graph_Arc Arc
The node class type.
Arc * insert_arc(Node *src_node, Node *tgt_node, void *a)
Iterator on nodes and arcs of a path.
Forward declaration used by CRTP helpers before the full node definition.
T & get_key() noexcept
Returns a modifiable reference to the node contents.
NodeInfo & get_info() noexcept
Return a modifiable reference to the data contained in the node.
constexpr size_t get_num_nodes() const noexcept
Return the total of nodes of graph.
Node * get_src_node(Arc *arc) const noexcept
Return the source node of arc (only for directed graphs)
Node * get_connected_node(Arc *arc, Node *node) const noexcept
Return the adjacent node to node through arc.
constexpr size_t get_num_arcs() const noexcept
Return the number of arcs of the graph.
Node * get_tgt_node(Arc *arc) const noexcept
Return the target node of arc (only for directed graphs)
Node * search_node(Op &op) const
Linear search of a node.
void deway(Tree_Node< int > *p, int prefix[], const int &len, const size_t &dim)
Recursively compute and print Deway numbering for a tree node.
Tree visualization and output generation.
Convert spanning tree graphs to Tree_Node structures.
Main namespace for Aleph-w library functions.
and
Check uniqueness with explicit hash + equality functors.
Arc of graph implemented with double-linked adjacency lists.
Node belonging to a graph implemented with a double linked adjacency list.
Iterator on all arcs of a graph.
bool operator()(const Ciudad &c1, const Ciudad &c2)
bool operator==(const Ciudad &c) const
Ciudad(const string &str)
void operator()(typename GT::Node *g, Tree_Node< string > *t)
static const Distance_Type Zero_Distance
Via(const string &nom, int d)
Distance_Type & get_distance()
const string operator()(Tree_Node< string > *p)
void imprimir_camino(Path< Mapa > &path)
void imprimir_mapa(Mapa &g)
List_Graph< Nodo_Ciudad, Arco_Via > Mapa
List_Digraph< Nodo_Ciudad, Arco_Via > Dimapa
Graph_Node< Ciudad > Nodo_Ciudad
Mapa::Node * buscar_ciudad(Mapa &mapa, const string &nombre)
Graph_Arc< Via > Arco_Via
void insert_via(Mapa &mapa, const string &c1, const string &c2, int distancia)
void construir_mapa(Mapa &g)
void escribir_deway(int deway[], const size_t &n)
Generic graph and digraph implementations.