Boost logo

Boost Users :

From: abhishek.v_at_[hidden]
Date: 2007-10-01 07:55:06


Hi

I m able to calculate whether the cycle exist in the graph or not. With
the help of following code..

//Finding out cycles
struct cycle_detector : public dfs_visitor<>
  {
 
    cycle_detector( bool& has_cycle, int&
num):_has_cycle(has_cycle),cycle(num)
    { }
    template <class Edge, class Graph>
    void back_edge(Edge, Graph&)
    {
      cycle++;
     _has_cycle = true;
    }
   protected:
    bool& _has_cycle;
    int& cycle;
  };

int main ()
{
......
....
....
//Finding out whether the graph has cycles..
bool has_cycle = false;
int count_cycle=0;
typedef Traits::vertices_size_type size_type;
cycle_detector vis(has_cycle,count_cycle);
boost::depth_first_search(g, visitor(vis));
if(has_cycle)
{
file_op << "\nThe graph is cyclic"<< std::endl;
file_op<<"\nNumber of cycles in the graph is "<<count_cycle;
}
else
std::cout << "The graph is acyclic"<< std::endl;

return 0;

}

Now what i want is to calculate the vertex between which the cycle exist
... How to calculate that..

Thanks
Abhishek Vyas
Tata Consultancy Services
Mailto: abhishek.v_at_[hidden]
Website: http://www.tcs.com
____________________________________________
Experience certainty. IT Services
                        Business Solutions
                        Outsourcing
____________________________________________
=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you



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