Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SimpleWeightedEdge ¶
type SimpleWeightedEdge struct {
F, T, W int
}
SimpleWeightedEdge is a simple implementation of the interface. Initialize with 'F' (From), 'T' (To), 'W' (Weight).
func (SimpleWeightedEdge) From ¶
func (s SimpleWeightedEdge) From() int
From returns the integer identifier of the first vertex.
func (SimpleWeightedEdge) To ¶
func (s SimpleWeightedEdge) To() int
To returns the integer identifier of the second vertex.
func (SimpleWeightedEdge) Weight ¶
func (s SimpleWeightedEdge) Weight() int
Weight returns the integer identifier of the weight/cost.
type WeightedEdge ¶
type WeightedEdge interface {
// From returns the integer identifier of the first vertex.
From() int
// To returns the integer identifier of the second vertex.
To() int
// Weight returns the integer identifier of the weight/cost.
Weight() int
}
WeightedEdge is an undirected edge between vertices and a weight.
func MinimumSpanningTree ¶
func MinimumSpanningTree(edges []WeightedEdge) []WeightedEdge
MinimumSpanningTree returns the fewest edges to span across the graph with the minimum cost based on weights.