dominikbraun / graph

A library for creating generic graph data structures and modifying, analyzing, and visualizing them.
https://graph.dominikbraun.io
Apache License 2.0
1.77k stars 95 forks source link

added Vertices() to Graph interface #149

Open jonbrandenburg opened 1 year ago

jonbrandenburg commented 1 year ago

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:

type Vertex[T any] struct {
    Value T
    Properties VertexProperties
}

Then this would enable the ability to create a Vertices() like this:

func Vertices() ([]Vertex[T], error)
AkashKumar7902 commented 5 months ago

Hey @dominikbraun, can this be merged ? I want this method more than ever.