Implement BFS shortest paths with reconstruction | MathWorks