pgraph: Filter graph should not include unfiltered vertices

This adds a test for another sneaky aspect of filter graph: It should
not pull in a vertex because another across the edge was included. If we
want this behaviour, then we need a different function or a config
option for this filter function.
This commit is contained in:
James Shubin
2024-01-07 18:05:41 -05:00
parent cb021e3a25
commit 58607e2ca0
2 changed files with 31 additions and 3 deletions

View File

@@ -213,6 +213,33 @@ func TestFilterGraph2(t *testing.T) {
}
}
func TestFilterGraph3(t *testing.T) {
G, _ := NewGraph("g5")
v1 := NV("v1")
v2 := NV("v2")
v3 := NV("v3")
v4 := NV("v4")
v5 := NV("v5")
e1 := NE("e1")
e2 := NE("e2")
G.AddEdge(v1, v2, e1)
G.AddEdge(v3, v4, e2)
G.AddVertex(v5)
save := []Vertex{v1, v2, v3}
out, err := G.FilterGraph("new g5", save)
if err != nil {
t.Errorf("failed with: %v", err)
}
if c, i := len(save), out.NumVertices(); c != i {
t.Errorf("should have %d vertices instead of: %d", c, i)
}
if c, i := 1, out.NumEdges(); c != i {
t.Errorf("should have %d edges instead of: %d", c, i)
}
}
func TestDisconnectedGraphs1(t *testing.T) {
G, _ := NewGraph("g6")
v1 := NV("v1")