![]() |
|
#1
|
|||
|
|||
shortest path algorithm and file savingI manage to implement all pairs shortest path algorithm
CPP / C++ / C Code:
This implementation have some weaknees: First this variable infinite is define as 999999 this is pretty much unfortunate. Do you have any suggestion regarding this issue? Second, there are weak chacking of user inputs, but I think I can manage this. Third, every time program is started user must enter graph manualy. Idea was to make this using files. So one can eneter name of file where graph is stored. First data in file would be int that represent number of nodes vertices, and then adjmatrix elements. I not good at working with files so I manage to screw this up with the following code: CPP / C++ / C Code:
I tried at the others forums but there was no response from anybode I hope you will help me Thanks in advance!!! Last edited by JdS : 08-May-2004 at 09:07.
Reason: Please enclose C code in [c] & [/c] for syntax highlighting
|
|
#2
|
|||
|
|||
|
what are the specific problems you are having reading from the file? Give output examples and specific code from your program that you think is causing the problem.
|
|
#3
|
|||
|
|||
|
Just compile and see for yorself.
I have VC++.net and having run time error: in file fopen.c ........... Expression *file !=_T( '\0' ); I'm also open for suggestion how to manage saving graph to file. I choose to save only adjmatrix. Maybe there aare some better way Thanks |
|
#4
|
||||
|
||||
|
Quote:
It's not surprising there was no response at other forums. __________________
Got a cough? Go home tonight and eat a whole box of Ex-Lax. Tomorrow, you'll be afraid to cough. -- Pearl Williams |
|
#5
|
|||
|
|||
|
figuring this out will take me a while with all the code, and plus i don't know anything about the c method of dealing with files using FILE*. I'll first have to read up on that. i'll post the reply in a little while if you can wait.
|
|
#6
|
|||
|
|||
|
Hey,
since your original code is written in C++, why resort to old C style FILE pointers? The fstream library is far better at handling it, and behaves very much similarily to iostream. WaltP also has a very valid point (except for needing VisualC++, your original code compiles grand with gcc). You're not giving us enough to work with here. Haven't you tried practising with file reading/writing before using it properly? Many of us (myself included) are unfamiliar with this algorithm, I've barely heard of Graphs myself. How do you wish to store the graph data? In the form of a table perhaps, as displayed www.brunel.ac.uk Could you explain the terminology, or even just show us the bits you're having trouble with? We can help you, but don't make us do your legwork. GF |
|
#7
|
|||
|
|||
|
Sorry guys, you're right.
That will not happen again, I promise. I figure out what is cusing run time error. My programs crashes with error message which tells that it happened in fopen.c. That means that error occures when trying to open files in that line CPP / C++ / C Code:
consider this much simpler problem: CPP / C++ / C Code:
I'm much better with good old C when it comes to dealing with files. I found in MSDN some infos so I use ofstream and ifstream. I use 80 character in ignore list, but that is not long therm solution, how big number I must enter, or there is a better way like flushing stdin in C? P.S. Are there someone of you who is good at graphs and Dijkstra algorithm especially? I need someone to consult with about shortest paths algorithms. Last edited by dsmith : 08-May-2004 at 14:13.
Reason: Changed code tags to c tags for highlighting
|
|
#8
|
|||
|
|||
Shortest path algorithmHi! I have to write a C++ Code for shortest path algorithm, but I don't know this language; the code written by Pandiani woulb be perfect but he says that it doesn't work in file reading/saving...
Could anybody help me? It's very important for me! Thanks |
|
#9
|
|||
|
|||
Re: shortest path algorithm and file savingHi ! I know this program is find shortest path so longest path can use it find out? Would you tell me how to find out longest path on this program? Thank you.
|
|
#10
|
|||
|
|||
Re: shortest path algorithm and file savingHi,
I have implemented the Dijkstra's shortest path with combinatoric, that is, given N nodes and L links, the program run all possible graphs and calculates the mean of hops. regards, |
Recent GIDBlog
Toyota - 2008 November Promotion by Nihal
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [Tutorial] Standard I/O | aaroncohn | C Programming Language | 20 | 27-Feb-2004 22:07 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The