Boost logo

Boost Users :

From: Daniele Carlucci (dax_at_[hidden])
Date: 2004-07-30 02:42:00


Hi everybody,
I wanna to print a graph but instead the id I want to print the name of
the same. How can I make?
I have token the list of the nodes from a list i. In i.name I have the
name of the node.
The code that I used to initialize the graph is:

template <class Graph>
void print(Graph& g) {
  typename Graph::vertex_iterator i, end;
  typename Graph::out_edge_iterator ei, edge_end;
  for(boost::tie(i,end) = vertices(g); i != end; ++i) {
  if (*i!=0){
    cout<< *i << " --> ";
    for (boost::tie(ei,edge_end) = out_edges(*i, g); ei != edge_end; ++ei)
    cout << target(*ei, g) << " ";
    cout << endl;}
  }
}

void Main()
{
int nodo, cont, a;
nodo=1;
  typedef graph_traits < file_dep_graph >::vertices_size_type size_type;
  size_type n_vertices; //Setta n_vertices con il numero di nodi
  n_vertices=id; // legge il numero di nodi
  file_dep_graph g(n_vertices);
  for (i=list.begin(); i != list.end(); ++i)
    {
    size_type k;
    for (cont=0; cont<(*i).v.size(); cont++)
        {
        a=(*i).v[cont]; //Connection between node "cont" and all the
other nodes
        add_edge((*i).PID, a, g);
        }
    }
print(g);

Thanks Daniele


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net