![]() |
|
#1
|
|||
|
|||
Need Help - Shortest Path ProblemHi,
I have implemented Dijkstra's algorithm before and now I have a project to implement another algorithm to solve the Shortest Path problem. This algorithm is known as Dantzig's algorithm. I have developed Directed Ascyclic Graph(DAG) and would like to use this algorithm to get the shortest path. Dantzig's algorithm: for s=1 to n do Single_Source(s) prosedure Single_Source(s) S={s} ; d[s]=0; initialize the set of candidates to {(s,t) }, where (s,t) is the shortest edge from s Dantzig_expand_S(n) end {Single_Source} prosedure Dantzig_expand_S(limit) while|s| < limit do begin let (c, t) be the candidate of least weight, where the weight of (c,t) is given by d[c] + c(c,t); S = S + {t}; d[t] = d[c] + c(c,t); if |s| = limit then break; add to the set of candidates the shortest useful edge from t; for each useless candidate (v,t) do replace (v,t) in the set of candidates by the next shortest useful edge from v end for end while end {Dantzig_expand_S } end for My Question : I am confuse about to build the set of candidates. If anyone can help, I really appreaciate it. |
|||
|
#2
|
|||
|
|||
Re: Need Help - Shortest Path ProblemQuote:
As for how to construct a "set", the simplest solution would be to create an array large enough to handle all the edge structures discussed above. If this is code which will only be used once or only a few times, this may be sufficient. If you expect to use it again & again, you may want something more sophisticated as in creating a linked list of these structures, however, this also depends upon your knowledge of C & whether you have time to debug all the details. You may also want to sort this array/linked list once populated given that it appears you want to continually pull off the shortest path on each iteration. |
|
#3
|
|||
|
|||
Re: Need Help - Shortest Path ProblemThank you ocicat.
I've declared all the vertices together with their edges. I generated them using rand( ) . For Example: OUT(0) = {(0,2),(0,3),(0,4)} with cost {d[0,2] = 4 ,d[0,3] = 3, d[0,4] = 1} CPP / C++ / C Code:
If I want to sort all the OUT(0) vertices, should I use Array or linked list ? How to sort them ? Last edited by admin : 17-Jun-2008 at 04:01.
Reason: Please insert your example C/C++ codes between [CPP] and [/CPP] tags
|
|
#4
|
|||
|
|||
Re: Need Help - Shortest Path ProblemQuote:
|
|
#5
|
|||
|
|||
Re: Need Help - Shortest Path ProblemThanks again ocicat. I appreciate it so much.
I have sorted vertices from the first vertex ( OUT(StartVertex) ) using a simple array as you suggested. My coding is just like this: CPP / C++ / C Code:
Is that what you have suggested ? |
|
#6
|
|||
|
|||
Re: Need Help - Shortest Path ProblemQuote:
|
Recent GIDBlog
Accepted for Ph.D. program by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Shortest Path Program. | bomber456 | C++ Forum | 1 | 05-Mar-2007 13:32 |
| shortest path algorithm and file saving | Pandiani | C++ Forum | 10 | 17-Jul-2006 11:46 |
| Graphic problem in Unreal Tournament 2004 | zerox | Computer Software Forum - Games | 10 | 09-Oct-2005 13:31 |
| a significant problem after installing Xp | mohammad | Computer Software Forum - Windows | 10 | 09-Aug-2005 08:03 |
| PATH points to nonexistent dir | wavez | C Programming Language | 5 | 06-Oct-2004 04:04 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The