Boost logo

Boost Users :

From: Stephen torri (storri_at_[hidden])
Date: 2004-09-21 21:15:21


I see that the boost graph library is used to contain data but can it be
used to contain a class which a visitor moves along the graph per a
preset algorithm calling interfacing functions as it moves along?

Here is an example.

class Color_Base
{
  virtual ~Color_Base(){}

  virtual std::string get_Name () = 0;
};

class Red : Color_Base
{
  virtual ~Red (){}

  virtual std::string get_Name ()
  { return std::string("Red"); }
};

class Yellow : Color_Base
{
  virtual ~Yellow (){}

  virtual std::string get_Name ()
  { return std::string("Yellow"); }
};

class Blue : Color_Base
{
  virtual ~Blue (){}

  virtual std::string get_Name ()
  { return std::string("Blue"); }
};

So we could have a graph like

 |
Blue -- Red
 | /
 | /
 | /
 Yellow

I have a visitor called Color_Visitor which has the following pseudo
code:

for each vertice in graph
  visit vertice
    call get_Name()
    print result

Stephen

-- 
Email: storri_at_[hidden]

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