User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C# section within the Software Development category of DaniWeb, a massive community of 402,975 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,645 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C# advertiser: Programming Forums
Views: 356 | Replies: 3 | Solved
Reply
Join Date: Jul 2008
Posts: 3
Reputation: alexutza_r_m is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
alexutza_r_m alexutza_r_m is offline Offline
Newbie Poster

Graphs

  #1  
Jul 3rd, 2008
Hi, everybody!

I am new to this forum.

I have a problem with an oriented weighted graph, more precisely, I have to find the shortest path between 2 nodes, but this path should pass through a given intermediary node. For example, I have a graph with 5 nodes, namely A, B, C, D, E. I have to find the shortest path from A to E, but this path should involve node C as well. With the weights the graph has, the shortest path should be, for example, A-B-D-E.

I used Dijkstra's algorithm to find the shortest path from A to E, that is the path A-B-D-E. That worked out fine. But I have no idea how I could change the code to accept the node that I am interested in, that is node C.

If you have any ideas, I would be very grateful to you.

Thanks a lot.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Mar 2008
Posts: 23
Reputation: $dunk$ is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 5
$dunk$ $dunk$ is offline Offline
Newbie Poster

Re: Graphs

  #2  
Jul 3rd, 2008
It seems to me that you need to break the search into 2 separate operations. For example, if you start at A and want to end up at E, going through C then you would calculate the shortest path from A to C, then calculate the shortest path from C to E.
Reply With Quote  
Join Date: Jul 2008
Posts: 3
Reputation: alexutza_r_m is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
alexutza_r_m alexutza_r_m is offline Offline
Newbie Poster

Re: Graphs

  #3  
Jul 4th, 2008
Hi. Thank you a lot for the reply. I will use your idea and I will tell you the results.

Best regards.
Reply With Quote  
Join Date: Jul 2008
Posts: 3
Reputation: alexutza_r_m is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
alexutza_r_m alexutza_r_m is offline Offline
Newbie Poster

Re: Graphs

  #4  
Jul 4th, 2008
Thank you a lot. Your idea was great. It solved my problem.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C# Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the C# Forum

All times are GMT -4. The time now is 8:01 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC