There are a lot of algorithms out there doing this. The catchword is path-finding.
The best algorithm to learn from at the beginning is the good old Dijkstra http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm
Then for larger graphs (that are no maze) you might want an algorithm with some direction heuristics making evaluation faster like the A* algorithm. http://en.wikipedia.org/wiki/A*
There are others, but these are tthe two most common.
Update from the discussion:
From our discussion I think going trough all permutations of the "must have nodes" B|L|I|D|G|K|J, starting from A and then going to A again would be an approach to solve it:
// Prepare a two dimensional array for the permutations
Node permutation[permutationCount][7];
// Fill it with all permutations
...
int cost[permutationCount];
for (int i = 0; i < permutationCount; ++i) {
cost[i] = dijkstraCost(nodeA, permutation[i][0])
+ dijkstraCost(permutation[i][0], permutation[i][1])
+ dijkstraCost(permutation[i][1], permutation[i][2])
+ dijkstraCost(permutation[i][2], permutation[i][3])
+ dijkstraCost(permutation[i][3], permutation[i][4])
+ dijkstraCost(permutation[i][4], permutation[i][5])
+ dijkstraCost(permutation[i][5], permutation[i][6])
+ dijkstraCost(permutation[i][6], nodeA);
}
// Now Evaluate lowest cost and you have your shortest path(s)
....
I think that should work.