Documentation
¶
Index ¶
- type AdjacencyList
- func (a *AdjacencyList) AddEdge(n1, n2 *Vertex)
- func (a *AdjacencyList) AddNode(node *Vertex)
- func (a *AdjacencyList) Copy() AdjacencyList
- func (a *AdjacencyList) EdgeCount() int
- func (a *AdjacencyList) FirstNode() *Vertex
- func (a *AdjacencyList) Genus() int
- func (a *AdjacencyList) HasNode(node Vertex) bool
- func (a *AdjacencyList) MinimalVertexCover() map[string]*Vertex
- func (a *AdjacencyList) NodeCount() int
- func (a *AdjacencyList) NodeWithMostEdges() *Vertex
- func (a *AdjacencyList) Nodes() map[string]*Vertex
- func (a *AdjacencyList) RemoveNode(node *Vertex)
- func (a *AdjacencyList) RemoveOrphans()
- func (a *AdjacencyList) Serialize(title string) string
- func (a *AdjacencyList) ValueLowest() *Vertex
- func (a *AdjacencyList) ValueSum() int
- func (a *AdjacencyList) Whiskers() map[string]*Vertex
- type Vertex
- func (v *Vertex) AddNeighbor(node *Vertex)
- func (v *Vertex) Decrement()
- func (v *Vertex) EdgeCount() int
- func (v *Vertex) FirstNeighbor() *Vertex
- func (v *Vertex) HasNeighbor(node Vertex) bool
- func (v *Vertex) ID() string
- func (v *Vertex) Increment()
- func (v *Vertex) Name() string
- func (v *Vertex) Neighbors() map[string]*Vertex
- func (v *Vertex) RemoveNeighbor(node Vertex)
- func (v *Vertex) SetName(name string)
- func (v *Vertex) SetValue(value int)
- func (v *Vertex) Value() int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdjacencyList ¶
type AdjacencyList struct {
// contains filtered or unexported fields
}
AdjacencyList implements an undirected graph
func (*AdjacencyList) AddEdge ¶
func (a *AdjacencyList) AddEdge(n1, n2 *Vertex)
AddEdge adds an edge, adding the nodes if they are not already present
func (*AdjacencyList) AddNode ¶
func (a *AdjacencyList) AddNode(node *Vertex)
AddNode adds a node to the adjacency list if not already present
func (*AdjacencyList) Copy ¶
func (a *AdjacencyList) Copy() AdjacencyList
Copy returns a copy of the AdjacencyList
func (*AdjacencyList) EdgeCount ¶
func (a *AdjacencyList) EdgeCount() int
EdgeCount returns the number of distinct edges in the adjacency list
func (*AdjacencyList) FirstNode ¶
func (a *AdjacencyList) FirstNode() *Vertex
FirstNode returns a node from the map
func (*AdjacencyList) Genus ¶
func (a *AdjacencyList) Genus() int
Genus returns the genus number of the adjacency list
func (*AdjacencyList) HasNode ¶
func (a *AdjacencyList) HasNode(node Vertex) bool
HasNode returns true if the node is already in the adjacency list
func (*AdjacencyList) MinimalVertexCover ¶
func (a *AdjacencyList) MinimalVertexCover() map[string]*Vertex
MinimalVertexCover returns vertices that make a minimal (not guaranteed to be minimum) vertex cover
func (*AdjacencyList) NodeCount ¶
func (a *AdjacencyList) NodeCount() int
NodeCount returns the number of nodes in the adjacency list
func (*AdjacencyList) NodeWithMostEdges ¶
func (a *AdjacencyList) NodeWithMostEdges() *Vertex
NodeWithMostEdges returns the node with the highest edge count
func (*AdjacencyList) Nodes ¶
func (a *AdjacencyList) Nodes() map[string]*Vertex
Nodes returns the map of nodes in the adjacency list
func (*AdjacencyList) RemoveNode ¶
func (a *AdjacencyList) RemoveNode(node *Vertex)
RemoveNode removes a node from the adjacency list
func (*AdjacencyList) RemoveOrphans ¶
func (a *AdjacencyList) RemoveOrphans()
RemoveOrphans removes all vertices that have no edges
func (*AdjacencyList) Serialize ¶
func (a *AdjacencyList) Serialize(title string) string
Serialize returns the adjacency list in graphviz format
func (*AdjacencyList) ValueLowest ¶
func (a *AdjacencyList) ValueLowest() *Vertex
ValueLowest returns the node with the lowest value
func (*AdjacencyList) ValueSum ¶
func (a *AdjacencyList) ValueSum() int
ValueSum returns the sum of all node values
func (*AdjacencyList) Whiskers ¶
func (a *AdjacencyList) Whiskers() map[string]*Vertex
Whiskers returns a map of vertices that have only one edge
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) FirstNeighbor ¶
FirstNeighbor returns the first neighbor
func (*Vertex) HasNeighbor ¶
HasNeighbor returns true if the given vertex is already a neighbor
func (*Vertex) RemoveNeighbor ¶
RemoveNeighbor removes a neighbor vertex