Click anywhere, and the pink circle will get as close as possible to where you clicked by traversing only on the directional node graph. In example one, you can move the nodes by dragging them around. Pressing Keys 1 and 2 will show two different graph examples, one being directed, the other undirected This project is a demonstration of my implementation of Dijkstra's Algorithm, a process used to find the shortest distance between nodes in a graph. My rendition uses node positions and directed edges of unknown length. The edge length is calculated when needed, and keeps a predecessor array to find paths to a node later on. This works with any situation; there can be dead ends, loops, as well as unreachable nodes, and it will function without error. (as long as the nodes are created properly) If reachable, the shortest path to a target node from a source node is found by tracing the predecessors from the target to the source, and tracking in reverse. This works completely using computations; no visuals are needed. These visual demonstrations are a little convoluted, but this system is versatile and can work for near all complexities.
Inspired by https://scratch.mit.edu/projects/922935840/ More information on Dijkstra's Algorithm: https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm All code by me! Feel free to use this (with credit) for projects involving pathfinding. Directed node graph visualizer by me: https://scratch.mit.edu/projects/1022374425/ (my examples don't really highlight its power in finding the most efficient path, but hopefully you can see its potential)