Graph Theory and Dijkstra / A* Algorithms: Mathematical Foundations and Implementation of Pathfinding