added Vertices() to Graph interface - #149
jonbrandenburg wants to merge 1 commit into
Conversation
dominikbraun
left a comment
There was a problem hiding this comment.
Thanks! Yes, a Vertex type would be more convenient for the use case where all full vertex instances should be retrieved, but that's a too large of a change right now. If one really needs this functionality, this should do the job:
for hash, _ := range g.AdjacencyMap() {
vertex, properties, _ := g.VertexWithProperties(hash)
}| Vertex(hash K) (T, error) | ||
|
|
||
| // Vertices returns a slice of all vertices in the graph. These vertices are of type | ||
| // Vertice[K] and hence will contain the vertex hashes, not the vertex values. |
There was a problem hiding this comment.
should this read K rather than Vertice[K]?
There was a problem hiding this comment.
should this read
Krather thanVertice[K]?
@alexnguyenatwork Yes. There is no Vertex type (let alone Vertice).
|
Hey @dominikbraun, |
|
@dominikbraun another friendly ping wondering if it's possible to merge this yet? I'm able to get the vertices by doing something like adjMap, err := g.graph.AdjacencyMap()
if err != nil {
return nil, err
}
vertices := make(K, 0, len(adjMap))
i := 0
for hash := range adjMap {
vertex, err := g.graph.Vertex(hash)
if err != nil {
return nil, err
}
vertices[i] = vertex
i++
}but it'd be nice to get this with a function public in the API |
|
Hi @dominikbraun can we have this one merged? Thanks! |
|
Hey @dominikbraun Gentle nudge on this. It'll be nice to get this merged. |
Merges dominikbraun#149 , albeit with `ListVertices`, to save `Vertices` for a future Vertex type.
This is a proposed solution to #130. Alternatively I could see renaming this to ListVertices() and adding a Vertices() that returns the actual vertices, though that might be more challenging since there is currently no Vertex type so conveying the VertexProperties would not happen as it does with Edges() and their corresponding EdgeProperties.
Building on the earlier idea, it might be beneficial to introduce a Vertex type:
Then this would enable the ability to create a Vertices() like this: