
Hi this message may have been sent twice as i got an error on my previous post, if so I apologize I'd like to build a boost graph from my own graph representation which is made of: std::vector<tNode*> => vertices std::set<std::pair<tNode*,tNode*> > => edges (oriented) tNode is a custom struct which contains various data and 2 integer attribtues for coordinates x,y I need to compute XY for each node in order to display them I have done that with another lib but as BGL seems more recent I d like to evaluate it. I'm not a boost expert neither a template guru => therefore I have some problems (even after having read lot of examples). I'd like to have an example to understand how BGL works. 1) how to build a boost representation of my own graph (where boost nodes ID would be integer cast of tNode* so that I can feed back my own nodes with XY) 2) how to run a layout algorithm on the boost representation (kawai or any other else). Than you

any help would be appreciated in the meantime I have compiled layout_test.cpp with BCB6 and I had to change some files of the library Here is the modified code (it might help somebody) (note you have to define BOOST_NO_CV_SPECIALIZATIONS in your compiler options) I'm using boost 1 35. 2 files were modified. Changes are marked with "ERBRI CHANGE" ======================================================== relaxed_heap.hpp from line 33 class relaxed_heap { struct group; typedef relaxed_heap self_type; typedef std::size_t rank_type; public: typedef IndexedType value_type; typedef rank_type size_type; // ERBRI CHANGE // use a typedef and make it public typedef enum { smallest_key, stored_key, largest_key } group_key_kind; // ERBRI CHANGE private: /** * The kind of key that a group has. The actual values are discussed * in-depth in the documentation of the @c kind field of the @c group * structure. Note that the order of the enumerators *IS* important * and must not be changed. */ // ERBRI CHANGE // commented => original code // enum group_key_kind { smallest_key, stored_key, largest_key }; // ERBRI CHANGE ..... ======================================================== relaxed_heap.hpp from line 228 for (size_type i = start; i < end; ++i) { // if ( groups[i] && (!x->value || compare(*groups[i], *x->value))) { // ERBRI CHANGE => same code but if splitted in 2 if if ( groups[i] ) { if (!x->value || compare(*groups[i], *x->value) ) { x->kind = stored_key; x->value = groups[i]; } } } .... ======================================================== facade_iterator_category.hpp from line 145 BOOST_MPL_ASSERT_NOT(( is_convertible< /*typename ERBRI CHANGE => remove typename*/ iterator_category_to_traversal<Category>::type , Traversal >));

Hi Eric I am not really clear what you need. I am not an expert rather a newbie but I have used boost to make graphs Here are some sample code for making a graph make a graph.h file including (or make it all in one file what you prefer): #include <vector> #include <boost/graph/adjacency_list.hpp> #include <boost/graph/graph_traits.hpp> #include <boost/tuple/tuple.hpp> #include "properties.h" some of these might not be needed you should experiment with that (better to give you too many than too few). Proterties you can write at the top or include as a file. typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS, VertexProperties, EdgeProperties, GraphProperties> Graph; typedef boost::graph_traits<Graph> DirectedTraits; typedef DirectedTraits::vertex_descriptor DirectedVertex; typedef DirectedTraits::edge_descriptor DirectedEdge; typedef DirectedTraits::vertex_iterator VertexIterator; typedef DirectedTraits::edge_iterator DirectedEdgeIterator; Then you have defined a graph (first line) and vertex and edge descriptors and iterators (used when you load your graph into it) DirectedS makes a directed graph. you can make the properties in a properties.h file which you can include in the graph.h file Example of properties (if using string remember to include the string library): enum vertex_x_t{vertex_x}; enum vertex_y_t{vertex_y}; template <> struct property_kind<shipping_graph::vertex_x_t>{ typedef vertex_property_tag type; }; template <> struct property_kind<shipping_graph::vertex_y_t>{ typedef vertex_property_tag type; }; // Vertex properties typedef boost::property<vertex_x_t, int, boost::property<vertex_y_t, int, boost::property<boost::vertex_name_t, std::string> > > VertexProperties; You can do the same for edgeproperties and graphproperties To load your graph into the graph do: Graph _graph; using namespace boost; UnDirectedVertex v; UnDirectedEdge e; for (int i=0; i< <number of vertices>; i++) { v= add_vertex(graph); put(vertex_name, graph, v, boost::lexical_cast<std::string>(i)); put(vertex_x, graph, v, <your x coordinate>); put(vertex_y, graph, v, <your y coordinate>); } for each of your edges from i to j write: tie(e,inserted)= add_edge(i,j, graph); put(edge_name, graph, e, edgeName(i, j)); To print the graph you can use the iterators to go through the vertex list and edge list. I hope this explanation will help you make a boost graph. Best Line ________________________________ Fra: boost-users-bounces@lists.boost.org på vegne af Eric B Sendt: ma 07-07-2008 23:58 Til: boost-users@lists.boost.org Emne: [Boost-users] BGL Newbie Hi this message may have been sent twice as i got an error on my previous post, if so I apologize I'd like to build a boost graph from my own graph representation which is made of: std::vector<tNode*> => vertices std::set<std::pair<tNode*,tNode*> > => edges (oriented) tNode is a custom struct which contains various data and 2 integer attribtues for coordinates x,y I need to compute XY for each node in order to display them I have done that with another lib but as BGL seems more recent I d like to evaluate it. I'm not a boost expert neither a template guru => therefore I have some problems (even after having read lot of examples). I'd like to have an example to understand how BGL works. 1) how to build a boost representation of my own graph (where boost nodes ID would be integer cast of tNode* so that I can feed back my own nodes with XY) 2) how to run a layout algorithm on the boost representation (kawai or any other else). Than you _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Eric B
-
Line Blander Reinhardt