440 B
440 B
Search Algorithm 1
O(n^2)
Visit all nodes with shortest path
- Create a set for visited nodes
- Set current node to start node
- From the current node compare all outgoing nodes
- Select the outgoing node with lowest weight that is not marked as visited
- If a node was found:
- Mark current node as visited
- Push next node to stack
- Set next node to current node
- Otherwise:
- Return with current stack