Thread: urgent help plz
View Single Post
Old Feb 27th, 2006, 4:29 PM   #1
ergawy
Newbie
 
Join Date: Feb 2006
Posts: 7
Rep Power: 0 ergawy is on a distinguished road
urgent help plz

I am trying to make an algorithm to find cycles in an undirected unweighted graph and it works for small cycles but for bigger cycles it produces this runtime error
Unhandeled exception stack overflow
If anyone knows how to solve this problem please tell me and if you have a better algorithm I will be so glad if you send it.
thnaks in advance

here you are the code:

void find_cycle(graph g, int parent, int grand, int source)
{
cout<<"p "<<parent<<endl;
for(int i=0 ; i<g.degree[parent] ; i++)
if(g.edges[parent][i] != grand)
{
cout<<"c "<<g.edges[parent][i]<<endl;
if(g.edges[parent][i] == source)
{
cout<<"cycle"<<endl;
return;
}
find_cycle(g, g.edges[parent][i], parent, source);
}
}

if anyone of you is good in graphs and graph algorithms please I need your advice.I need you to tell me what books should I study and what are the references that are sufficient to me to be good in this aspect but please keep things simple
ergawy is offline   Reply With Quote