Visit all the nodes in flatten

This commit is contained in:
Asim Aslam 2019-10-10 14:35:11 +01:00
parent 1f5ebf330d
commit b2f99a27b7

View File

@ -27,16 +27,14 @@ func flatten(n network.Node, visited map[string]bool) []network.Node {
visited = make(map[string]bool)
}
// check if already visited
if visited[n.Id()] == true {
return nil
}
// create new list of nodes
var nodes []network.Node
// append the current node
nodes = append(nodes, n)
// check if already visited
if visited[n.Id()] == false {
// append the current node
nodes = append(nodes, n)
}
// set to visited
visited[n.Id()] = true