pgraph: FilterGraph doesn't need a name arg
It's not being consumed anywhere, so remove it. If you really want to rename the graph, this can be done as a second step.
This commit is contained in:
@@ -500,10 +500,10 @@ func (g *Graph) DFS(start Vertex) []Vertex {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FilterGraph builds a new graph containing only vertices from the list.
|
// FilterGraph builds a new graph containing only vertices from the list.
|
||||||
func (g *Graph) FilterGraph(name string, vertices []Vertex) (*Graph, error) {
|
func (g *Graph) FilterGraph(vertices []Vertex) (*Graph, error) {
|
||||||
newGraph := &Graph{Name: name}
|
newGraph, err := NewGraph(g.Name)
|
||||||
if err := newGraph.Init(); err != nil {
|
if err != nil {
|
||||||
return nil, errwrap.Wrapf(err, "could not run FilterGraph() properly")
|
return nil, err
|
||||||
}
|
}
|
||||||
for k1, x := range g.adjacency {
|
for k1, x := range g.adjacency {
|
||||||
contains := VertexContains(k1, vertices)
|
contains := VertexContains(k1, vertices)
|
||||||
@@ -539,7 +539,7 @@ func (g *Graph) DisconnectedGraphs() ([]*Graph, error) {
|
|||||||
dfs := g.DFS(start)
|
dfs := g.DFS(start)
|
||||||
// filter all the collected elements into a new graph
|
// filter all the collected elements into a new graph
|
||||||
// TODO: is this method of filtering correct here? && or || ?
|
// TODO: is this method of filtering correct here? && or || ?
|
||||||
newGraph, err := g.FilterGraph(g.Name, dfs)
|
newGraph, err := g.FilterGraph(dfs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errwrap.Wrapf(err, "could not run DisconnectedGraphs() properly")
|
return nil, errwrap.Wrapf(err, "could not run DisconnectedGraphs() properly")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ func TestFilterGraph1(t *testing.T) {
|
|||||||
//G.AddEdge(v6, v4, e6)
|
//G.AddEdge(v6, v4, e6)
|
||||||
|
|
||||||
save := []Vertex{v1, v2, v3}
|
save := []Vertex{v1, v2, v3}
|
||||||
out, err := G.FilterGraph("new g5", save)
|
out, err := G.FilterGraph(save)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("failed with: %v", err)
|
t.Errorf("failed with: %v", err)
|
||||||
}
|
}
|
||||||
@@ -203,7 +203,7 @@ func TestFilterGraph2(t *testing.T) {
|
|||||||
G.AddVertex(v4)
|
G.AddVertex(v4)
|
||||||
|
|
||||||
save := []Vertex{v1, v2, v3}
|
save := []Vertex{v1, v2, v3}
|
||||||
out, err := G.FilterGraph("new g5", save)
|
out, err := G.FilterGraph(save)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("failed with: %v", err)
|
t.Errorf("failed with: %v", err)
|
||||||
}
|
}
|
||||||
@@ -227,7 +227,7 @@ func TestFilterGraph3(t *testing.T) {
|
|||||||
G.AddVertex(v5)
|
G.AddVertex(v5)
|
||||||
|
|
||||||
save := []Vertex{v1, v2, v3}
|
save := []Vertex{v1, v2, v3}
|
||||||
out, err := G.FilterGraph("new g5", save)
|
out, err := G.FilterGraph(save)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("failed with: %v", err)
|
t.Errorf("failed with: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user