Documentation ¶
Index ¶
- func DisjointSetAlgorithm(g *graph) bool
- func NewGraph() *graph
- type DisjointSet
- type Edge
- type VerSet
- func (s VerSet) Add(v Vertex) error
- func (s VerSet) Cardinality() int
- func (s VerSet) Contains(v Vertex) bool
- func (s VerSet) Difference(other VerSet) VerSet
- func (s VerSet) Equal(other VerSet) bool
- func (s VerSet) Intersect(other VerSet) VerSet
- func (s VerSet) Remove(v Vertex) error
- func (s VerSet) Union(other VerSet) VerSet
- type Vertex
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DisjointSetAlgorithm ¶
func DisjointSetAlgorithm(g *graph) bool
DisjointSetAlgorithm check whether a cycle exists or not.
Types ¶
type DisjointSet ¶
type DisjointSet []VerSet
DisjointSet is a type consist of VerSets, each of the VerSet is disjoint.
func (DisjointSet) Equal ¶
func (d DisjointSet) Equal(other DisjointSet) bool
Equal checks whether d is same as other or not.
func (DisjointSet) FindSet ¶
func (d DisjointSet) FindSet(e Edge) (F, T VerSet)
FindSet returns VerSets. Each VerSet contains the Vertex represented by `e.From` and `e.To`.
func (DisjointSet) Union ¶
func (d DisjointSet) Union(A, B VerSet) DisjointSet
Union unions 2 VerSets to one.
type VerSet ¶
type VerSet map[Vertex]struct{}
VerSet represents a set of vertices.
func (VerSet) Cardinality ¶
Cardinality returns the number of elements in the Set.
func (VerSet) Difference ¶
Difference returns the difference of `s` and `other`. Difference have a referential transparency.
Click to show internal directories.
Click to hide internal directories.