Info about a graph with structure instead node

Hi all, I'm a newby in this library. I'm interested to make a graph of network. It's possible or is very hard to make? I want to have inside every node a struct. Thanks Daniele

On Jul 12, 2004, at 3:36 AM, Daniele Carlucci wrote:
Hi all, I'm a newby in this library. I'm interested to make a graph of network. It's possible or is very hard to make? I want to have inside every node a struct.
Anything is possible with the BGL :) This particular thing is too hard
to do at the moment, but will become much easier as soon as we release
1.32.0 (in about 2 weeks):
First step is to create a property tag for your struct:
enum vertex_mystruct_t { vertex_mystruct };
Now make that tag a full-fledged graph property tag:
namespace boost {
BOOST_INSTALL_PROPERTY(vertex, mystruct);
}
Now when you create your graph type, you can store a value of any type
X along with each vertex like this (the first three parameters can be
anything, of course):
struct X { int foo; };
typedef adjacency_list

Thanks for your help. But if I have a list of structures like this how can I implement a graph? typedef struct Conceptual { char* Name; char* Type; Conceptual* Next; Conceptual() {Next=NULL; Name=NULL; Type=NULL; } }; typedef Conceptual* ListPtr; I have think to create a univocal variable for every word and to create a dynamic matrix of connections or a pointer inside the list of structure, I haven't also decide. Thanks Daniele Doug Gregor wrote:
On Jul 12, 2004, at 3:36 AM, Daniele Carlucci wrote:
Hi all, I'm a newby in this library. I'm interested to make a graph of network. It's possible or is very hard to make? I want to have inside every node a struct.
Anything is possible with the BGL :) This particular thing is too hard to do at the moment, but will become much easier as soon as we release 1.32.0 (in about 2 weeks):
First step is to create a property tag for your struct:
enum vertex_mystruct_t { vertex_mystruct };
Now make that tag a full-fledged graph property tag:
namespace boost { BOOST_INSTALL_PROPERTY(vertex, mystruct); }
Now when you create your graph type, you can store a value of any type X along with each vertex like this (the first three parameters can be anything, of course):
struct X { int foo; };
typedef adjacency_list
> Graph; Graph g; // creating a graph instance To actually get at the X values for each vertex, we need to grab the property map:
property_map
::type X_map(get(vertex_mystruct, g)); Now, finally, we can get to the X structure for any vertex_descriptor v:
X_map[v].foo = 17;
In 1.32.0, the BGL will support "bundled properties", which means that this whole e-mail would boil down to:
typedef adjacency_list
Graph; Graph g; graph_traits<Graph>::vertex_descriptor v = ...; g[v].foo = 17; Doug
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

On Monday 19 July 2004 12:09 pm, Daniele Carlucci wrote:
Thanks for your help. But if I have a list of structures like this how can I implement a graph? typedef struct Conceptual { char* Name; char* Type; Conceptual* Next; Conceptual() {Next=NULL; Name=NULL; Type=NULL; } }; typedef Conceptual* ListPtr; I have think to create a univocal variable for every word and to create a dynamic matrix of connections or a pointer inside the list of structure, I haven't also decide.
You need to decide: (1) What are your nodes (2) What are your edges (3) What data goes into your nodes (4) What data goes into your edges The BGL handles (1) and (2) automatically, and you can attach (3) and (4) as I mentioned in my other message. Doug

I have decided that my nodes are every structure, the data that goes inside them are, for example, Name, Type, Id, Characters ecc ecc, I have no data that goes into the edge. Can you give me a working sample, I try to make one but isn't so simple... I cannot able to connect the sample that you gave me in your sample with my structure. Thanks Daniele Doug Gregor wrote:
On Monday 19 July 2004 12:09 pm, Daniele Carlucci wrote:
Thanks for your help. But if I have a list of structures like this how can I implement a graph? typedef struct Conceptual { char* Name; char* Type; Conceptual* Next; Conceptual() {Next=NULL; Name=NULL; Type=NULL; } }; typedef Conceptual* ListPtr; I have think to create a univocal variable for every word and to create a dynamic matrix of connections or a pointer inside the list of structure, I haven't also decide.
You need to decide: (1) What are your nodes (2) What are your edges (3) What data goes into your nodes (4) What data goes into your edges
The BGL handles (1) and (2) automatically, and you can attach (3) and (4) as I mentioned in my other message.
Doug
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

On Tuesday 20 July 2004 11:14 am, Daniele Carlucci wrote:
I have decided that my nodes are every structure, the data that goes inside them are, for example, Name, Type, Id, Characters ecc ecc, I have no data that goes into the edge. Can you give me a working sample, I try to make one but isn't so simple... I cannot able to connect the sample that you gave me in your sample with my structure. Thanks Daniele
The BGL documentation has several examples that are far better than I could come up with on-the-fly. The Kevin Bacon one is perhaps the best: http://www.boost.org/libs/graph/doc/kevin_bacon.html Doug
participants (2)
-
Daniele Carlucci
-
Doug Gregor