Leaves returns the slice of leaves of the graph
()
| 333 | |
| 334 | // Leaves returns the slice of leaves of the graph |
| 335 | func (g *Graph) Leaves() []*Vertex { |
| 336 | g.lock.Lock() |
| 337 | defer g.lock.Unlock() |
| 338 | |
| 339 | var res []*Vertex |
| 340 | for _, v := range g.Vertices { |
| 341 | if len(v.Children) == 0 { |
| 342 | res = append(res, v) |
| 343 | } |
| 344 | } |
| 345 | |
| 346 | return res |
| 347 | } |
| 348 | |
| 349 | // Roots returns the slice of "Roots" of the graph |
| 350 | func (g *Graph) Roots() []*Vertex { |