I'm trying to implement Dijkstra's algorithm for finding the shortest path with a node constraint in Matlab. Specifically, I want to force the path to go through a given set of nodes.
I have an adjacency matrix as input and I need the function to take a start node, end node, and constraint as an array. The algorithm should also be able to handle multiple constraints and execute quickly.
Here the shortest path between A and E is 7 A⇒B⇒E, But i want to get the shortest path between A and E going through C. Ideadly i want an algorithm that can find the shortest path between two nodes and going through one or more nodes.
Can anyone provide an explanation of how to modify Dijkstra's algorithm to handle these constraints and help me with the implementation in Matlab?
Thank you!