Basically I have a graph with 12 nodes (representing cities) and 13 edges (representing routes).
Now let's say that (randomly) I have a plan for visiting n nodes, departing from a specific one (A). So (having N <= (12-1)
) and then come to the starting point.
For what I've been looking, it seems almost like the Traveling Salesman Problem
but with the difference that in my salesman doesn't necessarily needs to visit all nodes.
What algorithm am I looking for?
EDIT
Apparently this is not going to be a TSP, because TSP says that the graph must be closed and we go through every city (node) only once. In my case, it can cross a city more than once, if it makes the route shorter.
A few more examples for what am I looking for:
Example one:
Depart from: A
Need to visit (B,D,E,L,G,J,K)
Come back to: A
Example two:
Depart from: A
Need to visit (B,C,D,G,H,I,J,K)
Come back to: A
Rules:
- Get shortest path
- No specific order
- Can visit one node (city) more than once
Remember, this is for a project in C, so this is just pre-coding research.