Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat algorithm can I use to find the shortest path between specified node types in a graph?
    primarykey
    data
    text
    <p>This is the problem:</p> <p>I have n points (p1, p2, p3, .. pn), each of them can connect to any other with a determined cost x.</p> <p>Each point belongs to one of a set of point-types (for example "A" "B" "C" "D"...).</p> <p>The input of the method is the path I want to follow, for example "A-B-C-A-D-B".</p> <p>The output is the shortest path connecting the points of the type I give in input so for example "p1-p4-p32-p83-p43-p12" where p1 is an A-type, p4 a B-type, p32 a C-type, p83 an A-type, p43 a D-type and p12 a B-type.</p> <p>The "easy" solution consists of calculating ALL the possible paths but the computational cost is very high!</p> <p>Can someone find a better algorithm?</p> <p>As I said in title, I don't know if it exists!</p> <p>Update:</p> <p>The key point that prevents me from using Dijkstra and the other similar algorithms is that I have to link the points according to type.</p> <p>As input I have an array of types and I have to link in that order.</p> <p>This is an image of Kent Fredric (thanks a lot) which describes the initial situation (in red allowed links)!</p> <p><a href="http://img13.imageshack.us/img13/3856/immagineaol.jpg">alt text http://img13.imageshack.us/img13/3856/immagineaol.jpg</a></p> <p>A real life example:</p> <p>A man wants to visit a church in the morning, go to restaurant and finally visit a museum in the afternoon.</p> <p>In the map there are 6 churchs, 30 restaurants and 4 museums.</p> <p>He wants that the distance church-rest-museum is the minimum possible.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload