Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Feb 27th, 2006, 3: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
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:52 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC