hmdsefi / gograph

A golang generic graph library that provides mathematical graph-theory and algorithms.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feat] Successors and Predecessors methods out of the box

Tochemey opened this issue · comments

We all know that in a dag the edges are directed: that is, they have a direction, proceeding from a source vertex to a destination vertex. The destination vertex is a successor of the source, and the the source is a predecessor of the destination. So given a vertex, I think it will be nice to know all its successors and predecessors. This is the template for both functions:

  • Successors(ctx context.Context, source Vertex) []Vertex
  • Predecessors(ctx context.Context, source Vertex) []Vertex

@hmdsefi I hope this help.

@Tochemey thank you for creating the issue. Could you please add a description? it would be great if you add method names, inputs, and expected output with example.