algorithm - Dijkstra's alghoritm second minimum way -
so have next task:find minimum , second minimum way(which can same) value in graph , use dijkstra's alghoritm. first minimum good(just use alghoritm) have problem finding second minimum.tried find way ,based on first minimum way, smallest difference that's isn't working because second minimum way can different first.so ideas on finding second minimum way?
assuming store distance in array distance[x]
representing distance node x
, can switch array matrix
. so, every node x
you'll have list of values stored in distance[x]
. on, use of values compute distances node adjacent x
. after finished, can select line destination node , pick second minimum value there.
Comments
Post a Comment