test: Add a test for AddEdge

This commit is contained in:
Matthew Lesko-Krleza
2021-05-30 20:27:29 -04:00
parent 453fe18d7f
commit d285aaedc9

View File

@@ -75,6 +75,27 @@ func TestAddVertex1(t *testing.T) {
}
}
func TestAddEdge1(t *testing.T) {
g, _ := NewGraph("g")
v1 := NV("v1")
v2 := NV("v2")
g.AddVertex(v1)
g.AddVertex(v2)
if i := g.NumEdges(); i != 0 {
t.Errorf("should have 0 edges but got %d", i)
}
e1 := NE("e1")
g.AddEdge(v1, v2, e1)
if i := g.NumEdges(); i != 1 {
t.Errorf("should have 1 edge but got %d", i)
}
}
func TestDFS1(t *testing.T) {
G, _ := NewGraph("g3")
v1 := NV("v1")