|
Boost Users : |
From: ¹Ú±â¼ö (park_at_[hidden])
Date: 2002-06-07 01:21:34
Thank you for your answer, Jeremy Siek.
but I can't be cheered. ( ^^; )
1. I ordered BGL book and will get it in 10 days.
( I live in korea, the 2002 FIFA world cup co-host. but not sell BGL book.)
2. Before Creating my graph structure and interface, what I want to do is :
(1) Add object pointer to integer graph(object has an integer ID).
(2) Bind the object's member function to visitor object.
for example,
using namespace std;
using namespace boost;
class MyVertexObject
{
:
public:
Draw();
private:
int m_id;
};
vector <MyVertexObject* > DrawVector;
struct draw_visitor : public default_bfs_visitor
{
template<typename Vertex, function f, typename Graph>
void do_something_vertex(Vertex u, Graph& g)
{
u->f();
}
};
int main()
{
Graph graph;
:
draw_vistor<MyVertexObject*, mem_fn(MyDrawObject::Draw())> vis;
graph_traits<Graph>::vertex_iterator vs, ve;
tie(vs, ve) = vertices(graph);
graph_traits<Graph>::vertex_descriptor starter = *vs;
breadth_first_search(graph, starter, visitor(vis) );
:
}
I agree that above code is akward. but How about my intents? Is it akward, either?
----- Original Message -----
From: "Jeremy Siek" <jsiek_at_[hidden]>
Newsgroups: gmane.comp.lib.boost.user
Sent: Friday, June 07, 2002 4:22 AM
Subject: Re: [BGL] How can I use vertex object rather than integer?
Hello,
You can't use your own vertex and edge classes with the adjacency_list
class, however you can add extra data to the vertices and edges using
internal properties. Page 52 of the BGL book has an explanation and
examples.
Also, of course you can create you own graph structure and then implement
the BGL interface. Then all the BGL algorithms will work with your graph.
You might find Chapter 10 of the BGL book helpful in doing this.
Cheers,
Jeremy
On Wed, 5 Jun 2002, ¹Ú±â¼ö wrote:
yg-boo> for example,
yg-boo>
yg-boo> class Node
yg-boo> {
yg-boo> public:
yg-boo> int m_id;
yg-boo> };
yg-boo>
yg-boo> class Edge
yg-boo> {
yg-boo> public:
yg-boo> int from_node_id;
yg-boo> int to_node_id;
yg-boo> };
yg-boo>
yg-boo> How can I use this class to make graph?
yg-boo> many examples show only integer id graph..
yg-boo>
yg-boo> thanks in advance
yg-boo>
----------------------------------------------------------------------
Jeremy Siek http://php.indiana.edu/~jsiek/
Ph.D. Student, Indiana Univ. B'ton email: jsiek_at_[hidden]
C++ Booster (http://www.boost.org) office phone: (812) 855-3608
----------------------------------------------------------------------
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