Documentation ¶
Index ¶
- func IsConnected(g *Graph) bool
- func NullHeuristic(node, goal uint64) int
- func Search(graph *Graph, start, goal uint64, algo SearchAlgorithm, heuristic Heuristic) ([]uint64, error)
- type Attr
- type Edge
- type Graph
- func (g *Graph) AddEdge(u, v uint64, weight int, attr Attr)
- func (g *Graph) AddNode(node uint64, attr Attr)
- func (g *Graph) DeleteEdge(u, v uint64)
- func (g *Graph) DeleteNode(node uint64)
- func (g *Graph) Edge(u, v uint64) (*Edge, bool)
- func (g *Graph) IsDirected() bool
- func (g *Graph) Len() int
- func (g *Graph) Neighbors(node uint64) ([]uint64, bool)
- func (g *Graph) Node(node uint64) (Attr, bool)
- func (g *Graph) Nodes() []uint64
- type Heuristic
- type MstAlgorithm
- type OpenQueue
- type OpenSet
- type OpenStack
- type SearchAlgorithm
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsConnected ¶
Connected returns whether the Graph is fully connected or not.
func NullHeuristic ¶
Types ¶
type Attr ¶
type Attr map[string]interface{}
Attr is a set of attributes associated to a node/edge. Keys are strings. Values can be anything.
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
Graph implementation. Each pair of nodes can only hold one edge between them (no parallel edges).
func MinimumSpanningTree ¶
func MinimumSpanningTree(graph *Graph, algo MstAlgorithm) (*Graph, error)
MinimumSpanningTree calculates the MST using the specified algorithm
func (*Graph) AddEdge ¶
AddEdge adds an edge (with its attributes) between nodes u and v If the nodes don't exist, they will be automatically created. If an u-v edge already existed, its attributes will be overridden.
func (*Graph) AddNode ¶
AddNode adds the given node to the Graph. If the node already exists, it will override its attributes.
func (*Graph) DeleteEdge ¶
DeleteEdge removes the u-v edge, if exists. If any of the nodes don't exist, nothing happens.
func (*Graph) DeleteNode ¶
DeleteNode removes a node entry from the Graph. Any edge associated with it will be removed too.
func (*Graph) Edge ¶
Edge returns the Edge associated with the u-v node pair. An extra bool flag determines whether the edge was found. In undirected graphs, the edge u-v is be the same as v-u.
func (*Graph) IsDirected ¶
IsDirected returns whether the Graph is directed or not.
func (*Graph) Neighbors ¶
Neighbors returns the list of nodes containing edges between the given node and them, ordered by ascending node uint64 value An extra bool flag determines whether the node was found.
type OpenSet ¶
OpenSet defines the functions that any container used to keep track of non-expanded nodes must implement
type SearchAlgorithm ¶
type SearchAlgorithm uint
Algorithm binds each search type to a constant unsigned integer
const ( BreadthFirstSearch SearchAlgorithm = iota DepthFirstSearch Dijkstra Astar )