IsAlmostEqualTo verifies if two WeightedGraphs can be considered almost equal
(b WeightedGraph)
| 15 | |
| 16 | // IsAlmostEqualTo verifies if two WeightedGraphs can be considered almost equal |
| 17 | func (a *WeightedGraph) IsAlmostEqualTo(b WeightedGraph) bool { |
| 18 | if len(*a) != len(b) { |
| 19 | return false |
| 20 | } |
| 21 | |
| 22 | for i := range *a { |
| 23 | if len((*a)[i]) != len(b[i]) { |
| 24 | return false |
| 25 | } |
| 26 | |
| 27 | for j := range (*a)[i] { |
| 28 | if (*a)[i][j] == Inf && b[i][j] == Inf { |
| 29 | continue |
| 30 | } |
| 31 | |
| 32 | if !almostEqual((*a)[i][j], b[i][j]) { |
| 33 | return false |
| 34 | } |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | return true |
| 39 | } |
| 40 | |
| 41 | func TestFloydWarshall(t *testing.T) { |
| 42 | var floydWarshallTestData = []struct { |
no test coverage detected