473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

stack overflow

hi :

my code creates a graph
vector <Node*> node_list_vector;

where

Expand|Select|Wrap|Line Numbers
  1. class Node
  2. {
  3.     public :
  4.     int id;
  5.     std :: vector< std :: pair<int,double> > weighted_adjacency_list;
  6.  
  7.     //construct the weighted graph    
  8.     Node(int key,std :: vector < std :: pair <int,double> > list)
  9.     {
  10.         id = key;
  11.         weighted_adjacency_list = list;
  12.         node_list_vector.push_back(this);
  13.     }
  14. };
  15.  
  16.  
i have to generate all possible paths from the graph ,but i get stack overflow wen i use the following code :

Expand|Select|Wrap|Line Numbers
  1.  //gets all possible paths starting from all possible valid nodes
  2. void get_all_paths()
  3. {
  4.  
  5.     node_list_vector_iter = node_list_vector.begin();
  6.  
  7.     //call the function to generate the paths that start from the specific node
  8.     while(node_list_vector_iter !=  node_list_vector.end())
  9.     {
  10.  
  11.         temp_weighted_vect.push_back(pair<int,double> (node_id,double(0)));
  12.         get_paths(node_id,temp_weighted_vect);
  13.         node_list_vector_iter++;    
  14.     }
  15. }
  16.  
  17. void get_paths(int node_id,vector<pair<int,double> >path)
  18. {
  19.  
  20.     if(!path.empty())
  21.     {
  22.         //do something 
  23.  
  24.     }
  25.     else
  26.     {    
  27.         //error
  28.  
  29.     }
  30.  
  31.  
  32.  
  33.     vector<pair <int,double > > weighted_neighbours = (node_list_vector[node_id])->weighted_adjacency_list;
  34.     vector<pair<int,double> >::iterator neighbours = weighted_neighbours.begin();
  35.  
  36.  
  37.     //prints the paths wen no further outgoing edges are available
  38.     if(((node_list_vector[node_id])->weighted_adjacency_list).empty())
  39.     {
  40.         return;
  41.     }
  42.     else
  43.     {    
  44.         while(neighbours != weighted_neighbours.end())
  45.         {
  46.             get_paths((*neighbours).first,path);
  47.             path.pop_back();
  48.             neighbours++;    
  49.         }
  50.     }
  51. }
  52.  
please let me know wats the problem with my code.
thanks in advance.
Mar 15 '08 #1
0 979

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: ip4ram | last post by:
I am quite puzzled by the stack overflow which I am encountering.Here is the pseudocode //define stack structure //function operating on stack void my_stack_function( function parameters) {...
7
by: Aguilar, James | last post by:
Hello all, To begin, yes, this -is- a homework assignment. However, it is for my Algorithms class, and my instructor has given us explicit permission to use "expert" groups like newsgroups, so...
19
by: Jim | last post by:
I have spent the past few weeks designing a database for my company. The problem is I have started running into what I believe are stack overflow problems. There are two tab controls on the form...
4
by: Victor | last post by:
Hello, I've got a situation in which the number of (valid) recursive calls I make will cause stack overflow. I can use getrlimit (and setrlimit) to test (and set) my current stack size. ...
2
by: David W. Walker | last post by:
I am attempting to port a C code that runs OK on a number of Linux and Unix machines to Windows XP using Visual Studio C++. I have set the program up as a console application, but when I try to run...
2
by: Ali | last post by:
Hi, I got stack overflow errors while using an unmanaged dll from managed c# application. When i use editbin.exe to increase stack size of app , it works. Is there a way to increase stack size of...
6
by: Daz | last post by:
Hi everyone! It is indeed, once again time for me to ask another stupid question. I have been searching around on the net for quite a while, and can't find anything that explains 'exactly'...
24
by: John | last post by:
I know this is a very fundamental question. I am still quite confused if the program call stack stack should always grows upwards from the bottom, or the opposite, or doesn't matter?? That means...
7
by: amit.atray | last post by:
Environement : Sun OS + gnu tools + sun studio (dbx etc) having some Old C-Code (ansi + KR Style) and code inspection shows some big size variable (auto) allocated (on stack) say for ex. char...
87
by: CJ | last post by:
Hello: We know that C programs are often vulnerable to buffer overflows which overwrite the stack. But my question is: Why does C insist on storing local variables on the stack in the first...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.