Documentation
¶
Overview ¶
Package graph implements a (directed) graph of orderable values.
Index ¶
- type Digraph
- func (dg Digraph[T]) AddEdge(from, to T) Digraph[T]
- func (dg Digraph[T]) AddEgdes(edges EdgeSlice[T]) Digraph[T]
- func (dg Digraph[T]) AddVertex(v T) Digraph[T]
- func (dg Digraph[T]) Clone() Digraph[T]
- func (dg Digraph[T]) Edges() (es EdgeSlice[T])
- func (dg Digraph[T]) Equal(other Digraph[T]) bool
- func (dg Digraph[T]) HasVertex(v T) bool
- func (dg Digraph[T]) IsDAG() (T, bool)
- func (dg Digraph[T]) Originators() *set.Set[T]
- func (dg Digraph[T]) ReachableVertices(startV T) (tc *set.Set[T])
- func (dg Digraph[T]) RemoveVertex(v T)
- func (dg Digraph[T]) Reverse() (revDg Digraph[T])
- func (dg Digraph[T]) SortReverse() (sl []T)
- func (dg Digraph[T]) Terminators() (terms *set.Set[T])
- func (dg Digraph[T]) TransitiveClosure(v T) (tc Digraph[T])
- func (dg Digraph[T]) Vertices() *set.Set[T]
- type Edge
- type EdgeSlice
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Digraph ¶
Digraph relates orderable values in a directional way.
func (Digraph[T]) AddEdge ¶
AddEdge adds a connection from `from` to `to`. Both vertices must be added before. Otherwise the function may panic.
func (Digraph[T]) AddEgdes ¶
AddEgdes adds all given `Edge`s to the digraph.
In contrast to `AddEdge` the vertices must not exist before.
func (Digraph[T]) AddVertex ¶
AddVertex adds an edge / vertex to the digraph.
func (Digraph[T]) Edges ¶
Edges returns an unsorted slice of the edges of the digraph.
func (Digraph[T]) Equal ¶
Equal returns true if both digraphs have the same vertices and edges.
func (Digraph[T]) HasVertex ¶
HasVertex returns true, if `v` is a vertex of the digraph.
func (Digraph[T]) IsDAG ¶
IsDAG returns a vertex and false, if the graph has a cycle containing the vertex.
func (Digraph[T]) Originators ¶
Originators will return the set of all vertices that are not referenced at the to-part of an edge.
func (Digraph[T]) ReachableVertices ¶
ReachableVertices calculates the set of all vertices that are reachable from the given vertex `startV`.
func (Digraph[T]) RemoveVertex ¶
func (dg Digraph[T]) RemoveVertex(v T)
RemoveVertex removes a vertex and all its edges from the digraph.
func (Digraph[T]) Reverse ¶
Reverse returns a graph with reversed edges.
func (Digraph[T]) SortReverse ¶
func (dg Digraph[T]) SortReverse() (sl []T)
SortReverse returns a deterministic, topological, reverse sort of the digraph.
Works only if digraph is a DAG. Otherwise the algorithm will not terminate or returns an arbitrary value.
func (Digraph[T]) Terminators ¶
Terminators returns the set of all vertices that does not reference other vertices.
func (Digraph[T]) TransitiveClosure ¶
TransitiveClosure calculates the sub-graph that is reachable from `v`.