Documentation ¶
Index ¶
- type Graph
- func (g *Graph[T]) AdjacentOf(from T) []T
- func (g *Graph[T]) GetEdge(from, to T) (float64, bool)
- func (g *Graph[T]) GetEdges() [][]*float64
- func (g *Graph[T]) GetVertices() []T
- func (g *Graph[T]) IndexOf(elem T) int
- func (g *Graph[T]) MakeTree(root T, info uc.Objecter, f tlt.NextsFunc[T]) (*tr.Tree[T], error)
- type WeightFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Graph ¶ added in v0.3.7
Graph represents a graph.
func NewGraph ¶ added in v0.3.7
func NewGraph[T uc.Objecter](vertices []T, f WeightFunc[T]) *Graph[T]
NewGraph creates a new graph with the given vertices.
Parameters:
- vertices: vertices in the graph.
Returns:
- *WeightedGraph: the new graph.
func (*Graph[T]) AdjacentOf ¶ added in v0.3.7
func (g *Graph[T]) AdjacentOf(from T) []T
AdjacentOf returns the adjacent vertices of the given vertex.
Parameters:
- from: the source vertex.
Returns:
- []T: the adjacent vertices.
func (*Graph[T]) GetEdge ¶ added in v0.3.7
GetEdge returns the weight of the edge between the given vertices.
Parameters:
- from: the source vertex.
- to: the destination vertex.
Returns:
- float64: the weight of the edge.
- bool: true if the edge exists, otherwise false.
func (*Graph[T]) GetEdges ¶ added in v0.3.7
GetEdges returns the edges in the graph.
Returns:
- [][]*float64: the edges.
func (*Graph[T]) GetVertices ¶ added in v0.3.7
func (g *Graph[T]) GetVertices() []T
GetVertices returns the vertices in the graph.
Returns:
- []T: the vertices.
func (*Graph[T]) IndexOf ¶ added in v0.3.7
IndexOf returns the index of the given element in the graph.
Parameters:
- elem: the element to find.
Returns:
- int: the index of the element, or -1 if not found.
type WeightFunc ¶
WeightFunc is a function that calculates the weight of an edge.
Parameters:
- from: the source vertex.
- to: the destination vertex.
Returns:
- float64: the weight of the edge.
- bool: true if the edge exists, otherwise false.
Click to show internal directories.
Click to hide internal directories.