Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions directed.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ func (d *directed[K, T]) Vertex(hash K) (T, error) {
return vertex, err
}

func (d *directed[K, T]) Vertices() ([]K, error) {
return d.store.ListVertices()
}

func (d *directed[K, T]) VertexWithProperties(hash K) (T, VertexProperties, error) {
vertex, properties, err := d.store.Vertex(hash)
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ type Graph[K comparable, T any] interface {
// doesn't exist.
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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this read K rather than Vertice[K]?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this read K rather than Vertice[K]?

@alexnguyenatwork Yes. There is no Vertex type (let alone Vertice).

Vertices() ([]K, error)

// VertexWithProperties returns the vertex with the given hash along with
// its properties or ErrVertexNotFound if it doesn't exist.
VertexWithProperties(hash K) (T, VertexProperties, error)
Expand Down
4 changes: 4 additions & 0 deletions undirected.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ func (u *undirected[K, T]) Vertex(hash K) (T, error) {
return vertex, err
}

func (u *undirected[K, T]) Vertices() ([]K, error) {
return u.store.ListVertices()
}

func (u *undirected[K, T]) VertexWithProperties(hash K) (T, VertexProperties, error) {
vertex, prop, err := u.store.Vertex(hash)
if err != nil {
Expand Down