Segmentation Fault Error?

asdasdsada
Last edited on
Compile the executable with debug symbols (-g). Re-run program to trigger the segfault. Load the executable and core file that was generated when the application segfaulted into gdb and look at the backtrace.
Can't compile and test without your pqueue.h file.

Lines 73,53,93: You have memory leaks in your program. Your allocate a Graph object at line 73, Vertex at line 53 and Edge at line 93, but never delete any of them.

Lines 60-62 are unnecessary in C++.


Last edited on
I'm not sure that pqueue.h does anything relevant at the moment - I removed it and compiled.

Change line 101 from
for(int i = 1 ; i <= g->nVertices; ++i) {
to
for(int i = 0 ; i < g->nVertices; ++i) {

Change line 112 from
for(int i = 1 ; i <= g->nVertices; ++i) {
to
for(int i = 0 ; i < g->nVertices; ++i) {

This then produced your desired output (but not in the stated order). I'm not sure what will happen when you want to do anything else.

You would do well to put in some prompts for the user - I was entering data blind.
Last edited on
Topic archived. No new replies allowed.