Open filiperecharte opened 1 year ago
Hi! You can iterate over all vertices like so:
adjacencyMap, _ := g.AdjacencyMap()
for vertex := range adjacencyMap {
// Do something with vertex.
}
The adjacency map is guaranteed to contain all vertices in the graph. If you want them as a slice, you can build it yourself – but it is likely that there will be a Vertices
method in the future.
I want to iterate through the vertices of a graph, but the graph type does not have that method, and visiting each one using DFS does not work since, during runtime, I have vertices with no edges connected. Even if I had, I could only iterate through edges and then access Vertices, using the method Edges() of the graph, but that will not make me go through a vertice only once. Is there any way I can get a slice of them like the method that exists in type Store ListVertices()?