Shortest path

Shortest path preview
remixableManimCE2Dalgorithmsloop

manim/shortest_path.py

"""Shortest path: Dijkstra relaxing outward from the source until the path lights.

Render (the driver does this for every palette; these are for eyeballing):
    P=/opt/homebrew/opt/python@3.11/bin/python3.11
    ASSET_MODE=still  $P -m manim -s -t -r 1600,1600 manim/shortest_path.py ShortestPath
    ASSET_MODE=motion $P -m manim -qh   -r 1600,1600 manim/shortest_path.py ShortestPathLoop
"""

import heapq

import numpy as np
from manim import (
    UP,
    Circle,
    Line,
    NumberPlane,

The full Manim source and the rendered video come with a plan.