MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / IsAlmostEqualTo

Method IsAlmostEqualTo

graph/floydwarshall_test.go:17–39  ·  view source on GitHub ↗

IsAlmostEqualTo verifies if two WeightedGraphs can be considered almost equal

(b WeightedGraph)

Source from the content-addressed store, hash-verified

15
16// IsAlmostEqualTo verifies if two WeightedGraphs can be considered almost equal
17func (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
41func TestFloydWarshall(t *testing.T) {
42 var floydWarshallTestData = []struct {

Callers 1

TestFloydWarshallFunction · 0.80

Calls 1

almostEqualFunction · 0.85

Tested by

no test coverage detected