clue/graph — pull request #68 by Andrewsville (2013-08-03 17:31:50+00:00)
Title: Infinite loop fix caused by the order vertexes are defined

This fixes issue #66

The problem is that in the second case the `Fhaculty\Graph\Algorithm\ShortestPath\Base::getEdgesToInternal()` method receives edges in order that causes an infinite loop.

In the first case edges are:
```
1 -- 2
2 -- 5
5 -- 6
```

In the second case:
```
1 -- 2
5 -- 6
2 -- 5
```

The end vertex is `6`. The problem is that the loop in the second case iterates over the array of edges and finds the second one suitable (that's OK). The current vertex becomes `5`. The loop breakes and starts from the beginning. And again the second one is suitable (that's not OK). That's why it creates and infinite sequence of vertices `6-5-6-5-6-5-6-5-...`.

Possible solutions are IMO two:

1. Don't break after you find a suitable edge.
2. Remove the edge from the array of all edges after you use it so that it is not available in the next iteration. That's what this PR does.

---

Bottomline1: Why exactly do you have to know the correct order of edges in order to sum their weight?
Bottomline2: Why do you have to sort the edges at all? Shouldn't the distinct algorithms logically know the order and return the edges in the right order?

Anyway we plan to use this library for warehouse optimization purposes and plan to use it on graphs with hundreds of vertices. It is quite possible that more PRs will follow :)