[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.c++

first attempt with boost::graph

Goran

12/12/2008 6:36:00 PM

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::operator<(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;
}

1 Answer

Noah Roberts

12/12/2008 8:09:00 PM

0

Goran wrote:
> 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.