[HELP]How can I print a name of a node in a graph?
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
Hi, I use a library, which itself use Boost. This library define #define Handle boost::shared_ptr But because I intende to use WINAPI , this definition results in a conflict c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinUser.h(3282): error C2751: 'boost::shared_ptr' : the name of a function parameter cannot be qualified because Handle appears in definitions in WINAPI RPCNSAPI RPC_STATUS RPC_ENTRY I_RpcNsSendReceive( IN PRPC_MESSAGE Message, OUT RPC_BINDING_HANDLE __RPC_FAR * Handle ); What should I do, if I have to keep the #define line in my library... JK
On Jul 30, 2004, at 2:42 AM, Daniele Carlucci wrote:
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:
You just need a property map that associates a name with each vertex: http://www.boost.org/libs/graph/doc/using_property_maps.html There's even an example in libs/graph/example/vertex-name-property.cpp Doug
participants (3)
-
Daniele Carlucci
-
Doug Gregor
-
Dr Jekyll