Documentation
¶
Overview ¶
Package gsdset implements set operations with the package graph/gsd.
Index ¶
- func FindSet(vtx *gsd.Vertex, ds []*DisJointSet) *gsd.Vertex
- func SortEdges(graph *gsd.Graph) *slice.Sequence
- func UnionByRep(rep1, rep2 *gsd.Vertex, ds *[]*DisJointSet) *[]*DisJointSet
- func UnionByVtx(vtx1, vtx2 *gsd.Vertex, ds *[]*DisJointSet) *[]*DisJointSet
- type DisJointSet
- type EdgeSlice
- type Set
- func (s Set) Clone() Set
- func (s Set) Contains(vtx *gsd.Vertex) bool
- func (s Set) Delete(vtx *gsd.Vertex) bool
- func (s Set) GetElements() []*gsd.Vertex
- func (s Set) Insert(vertices ...*gsd.Vertex)
- func (s Set) Intersection(a Set) []*gsd.Vertex
- func (s Set) IsEmpty() bool
- func (s Set) IsEqual(a Set) bool
- func (s Set) Size() int
- func (s Set) String() string
- func (s Set) Subset(a Set) bool
- func (s Set) Subtract(a Set) []*gsd.Vertex
- func (s Set) Union(a Set) []*gsd.Vertex
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindSet ¶
func FindSet(vtx *gsd.Vertex, ds []*DisJointSet) *gsd.Vertex
FindSet returns the Rep of the DisJointSet that vtx belongs to.
func SortEdges ¶
SortEdges sorts Edges of graph in an increasing order by its weight and return the sorted Edges in slice.
func UnionByRep ¶
func UnionByRep(rep1, rep2 *gsd.Vertex, ds *[]*DisJointSet) *[]*DisJointSet
UnionByRep joins two subsets each of which is represented by its Rep x and y. We pass pointer to update the input slice.
func UnionByVtx ¶
func UnionByVtx(vtx1, vtx2 *gsd.Vertex, ds *[]*DisJointSet) *[]*DisJointSet
UnionByVtx joins two subsets that contain x and y. It joins two subsets into a single subset and update the slice of DisJointSet.
Types ¶
type DisJointSet ¶
func GetSet ¶
func GetSet(vtx *gsd.Vertex, ds []*DisJointSet) *DisJointSet
GetSet returns the DisJointSet that vtx belongs to.
func MakeGraphSet ¶
func MakeGraphSet(graph *gsd.Graph) []*DisJointSet
MakeGraphSet creates a Set of Vertices from the input Graph.
func MakeSet ¶
func MakeSet(vtx *gsd.Vertex) *DisJointSet
MakeSet creates a Set of one input Vertex with the vertex as Rep.
func UnionDisJointSet ¶
func UnionDisJointSet(s1, s2 *DisJointSet) *DisJointSet
UnionDisJointSet creates a Set of Vertices from the input Graph, setting s1's Rep as a new Rep.
func (DisJointSet) SetContains ¶
func (s DisJointSet) SetContains(vtx *gsd.Vertex) bool
SetContains returns true if the value exists in the set.
func (DisJointSet) String ¶
func (s DisJointSet) String() string
String prints out the DisJointSet information.
type Set ¶
Set maps each Vertex of graph to its Representative of DisJointSet.
func InstantiateSet ¶
InstantiateSet instantiates a set object with initial elements.
func NewSet ¶
func NewSet() Set
NewSet returns a new Set. Map supports the built-in function "make" so we do not have to use "new" and "make" does not return pointer.
func (Set) Delete ¶
Delete deletes the value, or return false if the value does not exist in the Set.
func (Set) GetElements ¶
GetElements returns the set elements. It makes another slice to return keys in map. The keys that occur more than one are considered to occur once in this case.
func (Set) Intersection ¶
Intersection returns values common in both sets.