You are on page 1of 1

calculate distance

between that node and


the distance is lower than
Start the node before
the lowest distance so far?
(and draw a line with
turtle) true
false

replace with the


newly calculated don't replace with
distance the newly calculated
set up: distance
- set variables AND
- define total numbers of nodes AND
set that node as a
"nearest node" and make that node
make its checked checked state ON
state ON

create node class:


> coordinate End
> selected state select a node that both:
=traversed state is OFF All nodes are checked?
=checked state is OFF false
set every nodes traversed state
into OFF
true

add the starting node into the


"path" array
+
set every nodes check state into
sum all distances calculated in
OFF
create node objects equal to (total the path and store it inside
numbers of nodes) and put them in reset the values of variables (and array) "pathDistances" array redraw the path by using the
an array used for determining if the path is shortest starting point stored
(erase turtle draw) *this will make two of them fit in
> loop them and assign values for AND the same array number*
each object.
select a starting node that has not been
THEN used as a starting node yet

draw them using turtle library make the starting node traversed state false All nodes traversed? true
according to the assigned value into ON (aka "ive already been used as a
starting point, dont mess with me once
again in this path" state)
compare all the path by using
path distances value in the
array
false
All nodes has been traversed? then retrieve the path
from the array "node list"? corresponding to the distance
value

You might also like