Documentation
¶
Index ¶
- Variables
- func IsCycle(path []*Vertex) bool
- func IsPath(path []*Vertex) bool
- type AdjList
- func (a *AdjList) AddEdge(n1, n2 *Vertex)
- func (a *AdjList) AddNode(node *Vertex)
- func (a AdjList) Connected() bool
- func (a AdjList) Copy() AdjList
- func (a AdjList) EdgeCount() int
- func (a AdjList) FirstNode() *Vertex
- func (a AdjList) Genus() int
- func (a AdjList) HamiltonianPaths(minLength int, stopOnFirstPath bool, includeReverse bool) [][]*Vertex
- func (a AdjList) HasNode(node Vertex) bool
- func (a AdjList) MinimalVertexCover() map[uint64]*Vertex
- func (a AdjList) NodeCount() int
- func (a AdjList) NodeWithMostEdges() *Vertex
- func (a AdjList) Nodes() map[uint64]*Vertex
- func (a *AdjList) RemoveNode(node Vertex)
- func (a *AdjList) RemoveOrphans()
- func (a AdjList) Serialize(title string) string
- func (a AdjList) ValueLowest() *Vertex
- func (a AdjList) ValueSum() int
- func (a AdjList) Whiskers() map[uint64]*Vertex
- type Path
- type Vertex
- func (v *Vertex) AddNeighbor(node *Vertex)
- func (v *Vertex) Decrement()
- func (v *Vertex) Degree() int
- func (v Vertex) Equal(node Vertex) bool
- func (v Vertex) FirstNeighbor() *Vertex
- func (v Vertex) HasNeighbor(node Vertex) bool
- func (v Vertex) ID() uint64
- func (v *Vertex) Increment()
- func (v Vertex) Name() string
- func (v Vertex) NeighborCount() int
- func (v Vertex) Neighbors() []*Vertex
- func (v *Vertex) RemoveNeighbor(node Vertex)
- func (v *Vertex) SetName(name string)
- func (v *Vertex) SetValue(value int)
- func (v Vertex) SortNeighbors()
- func (v Vertex) Value() int
Constants ¶
This section is empty.
Variables ¶
var (
RunningID int64
)
Functions ¶
Types ¶
type AdjList ¶ added in v0.0.10
type AdjList struct {
// contains filtered or unexported fields
}
AdjList implements an undirected graph
func (*AdjList) AddEdge ¶ added in v0.0.10
AddEdge adds an edge, adding the nodes if they are not already present
func (*AdjList) AddNode ¶ added in v0.0.10
AddNode adds a node to the adjacency list if not already present
func (AdjList) Connected ¶ added in v0.0.10
Connected returns true if every vertex is reachable from every other vertex
func (AdjList) EdgeCount ¶ added in v0.0.10
EdgeCount returns the number of distinct edges in the adjacency list
func (AdjList) HamiltonianPaths ¶ added in v0.0.10
func (a AdjList) HamiltonianPaths(minLength int, stopOnFirstPath bool, includeReverse bool) [][]*Vertex
HamiltonianPaths returns paths, the traversal of which touch each vertex once
func (AdjList) HasNode ¶ added in v0.0.10
HasNode returns true if the node is already in the adjacency list
func (AdjList) MinimalVertexCover ¶ added in v0.0.10
MinimalVertexCover returns vertices that make a minimal (not guaranteed to be minimum) vertex cover
func (AdjList) NodeCount ¶ added in v0.0.10
NodeCount returns the number of nodes in the adjacency list
func (AdjList) NodeWithMostEdges ¶ added in v0.0.10
NodeWithMostEdges returns the node with the highest edge count
func (*AdjList) RemoveNode ¶ added in v0.0.10
RemoveNode removes a node from the adjacency list
func (*AdjList) RemoveOrphans ¶ added in v0.0.10
func (a *AdjList) RemoveOrphans()
RemoveOrphans removes all vertices that have no edges
func (AdjList) ValueLowest ¶ added in v0.0.10
ValueLowest returns the node with the lowest value
type Path ¶ added in v0.0.9
type Path struct {
// contains filtered or unexported fields
}
func (*Path) PopAndTrack ¶ added in v0.0.10
func (*Path) PushAndTrack ¶ added in v0.0.10
type Vertex ¶
type Vertex struct {
// contains filtered or unexported fields
}
Vertex implements a graph Vertex
func (*Vertex) AddNeighbor ¶
AddNeighbor adds a neighbor vertex
func (*Vertex) Degree ¶ added in v0.0.8
Degree returns the degree of the incoming edges (loops count as 2)
func (Vertex) FirstNeighbor ¶
FirstNeighbor returns the first neighbor
func (Vertex) HasNeighbor ¶
HasNeighbor returns true if the given vertex is already a neighbor
func (Vertex) NeighborCount ¶ added in v0.0.8
NeighborCount returns the number of edges (neighbors)
func (*Vertex) RemoveNeighbor ¶
RemoveNeighbor removes a neighbor vertex
func (Vertex) SortNeighbors ¶ added in v0.0.9
func (v Vertex) SortNeighbors()
NeighborsSorted returns a sorted slice of all neighbors