public System.Collections.IEnumerator FindPath(Vertex startVertex, Vertex goalVertex, System.Action <List <Edge> > callback = null) { openList.Add(startVertex, new PathRecord(startVertex)); PathRecord current = null; #region Not a part of algorithm, visualization purposes only gridMarkerController.PutOpenNodeMarker(startVertex); #endregion while (openList.Count > 0) { current = openList.PopMinValue(); #region Not a part of algorithm, visualization purposes only gridMarkerController.PutCurrentNodeMarker(current.node); #endregion if (current.node == goalVertex) { //WOW! we found goal! break; } yield return(ProcessAllEdgesFromCurrent(current, goalVertex)); closeList.Add(current.node, current); #region Not a part of algorithm, visualization purposes only gridMarkerController.RemoveMarker(current.node); gridMarkerController.PutClosedNodeMarker(current.node); #endregion yield return(new WaitForSecondsRealtime(sleepTime)); } List <Edge> path = new List <Edge>(); if (current.node == goalVertex) { while (current.node != startVertex) { #region Not a part of algorithm, visualization purposes only if (goalVertex != current.node) { gridMarkerController.PutPathNodeMarker(current.node); yield return(new WaitForSecondsRealtime(sleepTime)); } #endregion path.Add(current.connection.edge); current = current.connection.fromRecord; } path.Reverse(); } if (callback != null) { callback.Invoke(path); } }