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
#include
#include
#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 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{
typedef vertex_property_tag type;
};
template <> struct property_kind{
typedef vertex_property_tag type;
};
// Vertex properties
typedef boost::property > > 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_caststd::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 => vertices
std::set > => 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