kumpelblase2 / gka

GKA Aufgaben [Archive]
0 stars 0 forks source link

Breadth First Search #5

Closed sebdied closed 10 years ago

sebdied commented 10 years ago

breadth - Breitensuche

kumpelblase2 commented 10 years ago

Pseudocode Implementation

vars Start, Queue, End, Visited
Start = a node
End = a node
Queue = a queue
Visited = a map

while (Queue has items)
    Current = Queue removefirst
    for Node in Current
        if Node == End
            break
        endif

        if not Node in Visited
            Visited add Node
        endif

        Nodescore = (Current score) + (getedgescore Current to Node)
        if Nodescore < (Visited getscore Node)
            Visited setparent Node to Current
            Visited setscore Node to (Current score) + (getedgescore Current to Node)
        endif
    endfor
endwhile

if not End in Visited
    Error "End not in graph"
else
    Success "Path found, Score: " + Visited getscore End
endif
kumpelblase2 commented 10 years ago

Finished as of d45b9cb