Jump to content

Dijkstra's Algorithm (HELP)

- - - - -

  • Please log in to reply
8 replies to this topic

#1
toto_7

toto_7

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 295 posts
I would like to ask, when this algorithm finished, when you put all of the nodes in the tree and the fringe is empty, or when you reach the destination node?

#2
Momerath

Momerath

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 243 posts
It ends when all nodes have been visited.

#3
toto_7

toto_7

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 295 posts
So, what happened if you can't visit all nodes?

#4
Momerath

Momerath

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 243 posts
Well, since it's for a connected graph you'd have some issues now, wouldn't you.

#5
toto_7

toto_7

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 295 posts
The problem is that, node "A" goes to 3 different nodes, but no other node goes to "A". My restriction is that i have to start from "B" so always i can't visit "A"

#6
Momerath

Momerath

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 243 posts
Then all nodes have been visited.

#7
toto_7

toto_7

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 295 posts
What do you mean all nodes have been visited? what about "A"?

#8
Momerath

Momerath

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 243 posts
You don't make a big list of all the nodes in your graph and then 'remove' them as they are visited. You create a dynamic list from your starting node. And as you visit each node you add to this list any nodes that haven't already been visited (and remove the one you are at). When the 'nodes to visit' list is empty, you are done. In your case, node 'A' would never be added to the 'nodes to visit' list, as there is no way to get to it.

#9
toto_7

toto_7

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 295 posts
Can i have an example with this situation please?




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users