Esempio n. 1
0
void imprimir_arcos(Grafo & g, const long & color)
{
  cout << "Listado de arcos con color " << color << endl;
  for (Grafo::Arc_Iterator it(g); it.has_current(); it.next())
    {
      Grafo::Arc * arc = it.get_current_arc();

      if (g.get_counter(arc) == color)
	cout << "Arco de " << g.get_src_node(arc)->get_info().clave
	     << " a " << g.get_tgt_node(arc)->get_info().clave << endl;
    }
  cout << endl;
}
Esempio n. 2
0
void imprimir_arcos_corte(Grafo & g)
{
  cout << "Listado de arcos de corte *** " << endl;
  for (Grafo::Arc_Iterator it(g); it.has_current(); it.next())
    {
      Grafo::Arc * arc = it.get_current_arc();

      if (g.get_control_bits(arc).get_bit(Aleph::Cut))
	cout << "Arco de " << g.get_src_node(arc)->get_info().clave
	     << " a " << g.get_tgt_node(arc)->get_info().clave 
	     << " con color " << g.get_counter(arc) << endl;

    }
  cout << endl;
}
Esempio n. 3
0
/* Inspecciona los arcos de g en el cual se ha calculado un árbol
   abarcador. Si el arco no está en el árbol abarcador, entonces éste se
   inserta en arc_list */
void generate_non_tree_arcs(Grafo & g, // g donde se calculó árbol abarcador
			    DynDlist<No_Tree_Arc> & arc_list)
{
  for (Grafo::Arc_Iterator it(g); it.has_current(); it.next())
    {
      Grafo::Arc * arc = it.get_current_arc();

      Grafo::Arc * tarc = static_cast<Grafo::Arc*>(ARC_COOKIE(arc));

      if (tarc == NULL) // pertenece arco al árbol abarcador?
	{     // No, insertarlo en arc_list
	      // obtener nodos origen y destino en el árbol abarcador
	  Grafo::Node * src = g.get_src_node(arc);
	  Grafo::Node * tgt = g.get_tgt_node(arc);

	  arc_list.append(No_Tree_Arc(src, tgt));
	}
    }
}
Esempio n. 4
0
void imprimir_grafo(Grafo & g)
{
  cout << endl
       << "Listado de nodos (" << g.get_num_nodes() << ")" << endl;

  for (Grafo::Node_Iterator it(g); it.has_current(); it.next())
    cout << INDENT << it.get_current_node()->get_info().clave << endl;

  cout << endl
       << endl
       << "Listado de arcos (" << g.get_num_arcs() << ")"
       << endl;

  for (Grafo::Arc_Iterator it(g); it.has_current();it.next())
    {
      Grafo::Arc * arc = it.get_current_arc();
      cout << "Arco de " << g.get_src_node(arc)->get_info().clave
	   << " a " << g.get_tgt_node(arc)->get_info().clave << endl;
    }

  cout << endl
       << endl
       << "Listado del grafo por nodos y en cada nodo por arcos" 
       << endl;
  for (Grafo::Node_Iterator it(g); it.has_current(); it.next())
    {
      Grafo::Node * src_node = it.get_current_node();
      cout << src_node->get_info().clave << endl;
      for (Grafo::Node_Arc_Iterator itor(src_node); 
	   itor.has_current(); itor.next())
	{
	  Grafo::Arc * arc = itor.get_current_arc();

	  cout << INDENT 
	       << g.get_connected_node(arc, src_node)->get_info().clave
	       << endl;
	}
    }
  cout << endl;
}