first attempt with boost::graph


G

Goran

Hi all,

I'm trying to use boost::graph but I still don't have success.

I just want a simple tree with no multiple edges and vertexes. Further
no loops. E.g.:

0
/
1
/ \
3 5
\
8
\
4

Thanks for answering!

Here's my first attempt:
/////////////////////////////////

#include <boost/graph/adjacency_list.hpp>

class Page {

public:
Page(unsigned int aId);
virtual ~Page();

public:
unsigned int getId() const;

public:
bool operator<(const Page& rhs);

private:
unsigned int itsId;
};

Page::page(unsigned int aId):itsId(aId) {}

Page::~Page() {}

unsigned int Page::getId() const {return itsId;}

bool Page::eek:perator<(const Page& rhs) {

if(itsId < rhs.getId())
return true;
else
return false;
}

int main() {

using namespace std;
using namespace boost;

typedef boost::adjacency_list<
setS,
setS,
directedS,
Page,
Page> Graph;

Graph graph;

Page page1(1);
Page page2(2);
Page page3(3);

add_edge(page1,page2,graph);

return 0;
}
 
Ad

Advertisements

N

Noah Roberts

Goran said:
Hi all,

I'm trying to use boost::graph but I still don't have success.

I just want a simple tree with no multiple edges and vertexes. Further
no loops. E.g.:

0
/
1
/ \
3 5
\
8
\
4

Thanks for answering!

Boost has a user mailing list where you can get help for stuff like this.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top