Skip to content

Commit

Permalink
Fix test for ShortestPath for undirected graphs
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikbraun committed Mar 27, 2023
1 parent d1c7144 commit 465eb9e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions paths_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ func TestUndirectedShortestPath(t *testing.T) {
edges []Edge[string]
sourceHash string
targetHash string
isWeighted bool
expectedShortestPath []string
shouldFail bool
}{
Expand All @@ -320,6 +321,7 @@ func TestUndirectedShortestPath(t *testing.T) {
{Source: "F", Target: "G", Properties: EdgeProperties{Weight: 5}},
{Source: "G", Target: "B", Properties: EdgeProperties{Weight: 2}},
},
isWeighted: true,
sourceHash: "A",
targetHash: "B",
expectedShortestPath: []string{"A", "C", "E", "B"},
Expand All @@ -332,6 +334,7 @@ func TestUndirectedShortestPath(t *testing.T) {
{Source: "B", Target: "D", Properties: EdgeProperties{Weight: 2}},
{Source: "C", Target: "D", Properties: EdgeProperties{Weight: 2}},
},
isWeighted: true,
sourceHash: "A",
targetHash: "D",
expectedShortestPath: []string{"A", "B", "D"},
Expand Down Expand Up @@ -359,6 +362,7 @@ func TestUndirectedShortestPath(t *testing.T) {
{Source: "B", Target: "D", Properties: EdgeProperties{Weight: 2}},
{Source: "C", Target: "D", Properties: EdgeProperties{Weight: 2}},
},
isWeighted: true,
sourceHash: "B",
targetHash: "B",
expectedShortestPath: []string{"B"},
Expand All @@ -369,6 +373,7 @@ func TestUndirectedShortestPath(t *testing.T) {
{Source: "A", Target: "B", Properties: EdgeProperties{Weight: 2}},
{Source: "A", Target: "C", Properties: EdgeProperties{Weight: 4}},
},
isWeighted: true,
sourceHash: "A",
targetHash: "D",
expectedShortestPath: []string{},
Expand All @@ -378,6 +383,7 @@ func TestUndirectedShortestPath(t *testing.T) {

for name, test := range tests {
graph := New(StringHash)
graph.(*undirected[string, string]).traits.IsWeighted = test.isWeighted

for _, vertex := range test.vertices {
_ = graph.AddVertex(vertex)
Expand Down

0 comments on commit 465eb9e

Please sign in to comment.