Documentation ¶
Index ¶
- type DenseGraph
- func (g *DenseGraph) Cost(e graph.Edge) float64
- func (g *DenseGraph) Crunch()
- func (g *DenseGraph) Degree(n graph.Node) int
- func (g *DenseGraph) DirectedEdgeList() []graph.Edge
- func (g *DenseGraph) EdgeBetween(n, neighbor graph.Node) graph.Edge
- func (g *DenseGraph) EdgeTo(n, succ graph.Node) graph.Edge
- func (g *DenseGraph) Neighbors(n graph.Node) []graph.Node
- func (g *DenseGraph) NodeExists(n graph.Node) bool
- func (g *DenseGraph) NodeList() []graph.Node
- func (g *DenseGraph) Predecessors(n graph.Node) []graph.Node
- func (g *DenseGraph) RemoveEdge(e graph.Edge, directed bool)
- func (g *DenseGraph) SetEdgeCost(e graph.Edge, cost float64, directed bool)
- func (g *DenseGraph) Successors(n graph.Node) []graph.Node
- type DirectedGraph
- func (g *DirectedGraph) AddDirectedEdge(e graph.Edge, cost float64)
- func (g *DirectedGraph) AddNode(n graph.Node)
- func (g *DirectedGraph) Cost(e graph.Edge) float64
- func (g *DirectedGraph) Degree(n graph.Node) int
- func (g *DirectedGraph) EdgeBetween(n, neigh graph.Node) graph.Edge
- func (g *DirectedGraph) EdgeList() []graph.Edge
- func (g *DirectedGraph) EdgeTo(n, succ graph.Node) graph.Edge
- func (g *DirectedGraph) EmptyGraph()
- func (g *DirectedGraph) Neighbors(n graph.Node) []graph.Node
- func (g *DirectedGraph) NewNode() graph.Node
- func (g *DirectedGraph) NodeExists(n graph.Node) bool
- func (g *DirectedGraph) NodeList() []graph.Node
- func (g *DirectedGraph) Predecessors(n graph.Node) []graph.Node
- func (g *DirectedGraph) RemoveDirectedEdge(e graph.Edge)
- func (g *DirectedGraph) RemoveNode(n graph.Node)
- func (g *DirectedGraph) Successors(n graph.Node) []graph.Node
- type Edge
- type Graph
- func (g *Graph) AddNode(n graph.Node)
- func (g *Graph) AddUndirectedEdge(e graph.Edge, cost float64)
- func (g *Graph) Cost(e graph.Edge) float64
- func (g *Graph) Degree(n graph.Node) int
- func (g *Graph) EdgeBetween(n, neigh graph.Node) graph.Edge
- func (g *Graph) EdgeList() []graph.Edge
- func (g *Graph) EmptyGraph()
- func (g *Graph) Neighbors(n graph.Node) []graph.Node
- func (g *Graph) NewNode() graph.Node
- func (g *Graph) NodeExists(n graph.Node) bool
- func (g *Graph) NodeList() []graph.Node
- func (g *Graph) RemoveNode(n graph.Node)
- func (g *Graph) RemoveUndirectedEdge(e graph.Edge)
- type Node
- type TileGraph
- func (g *TileGraph) CoordsToID(row, col int) int
- func (g *TileGraph) CoordsToNode(row, col int) graph.Node
- func (g *TileGraph) Cost(e graph.Edge) float64
- func (g *TileGraph) Degree(n graph.Node) int
- func (g *TileGraph) Dimensions() (rows, cols int)
- func (g *TileGraph) EdgeBetween(n, neigh graph.Node) graph.Edge
- func (g *TileGraph) EdgeList() []graph.Edge
- func (g *TileGraph) IDToCoords(id int) (row, col int)
- func (g *TileGraph) Neighbors(n graph.Node) []graph.Node
- func (g *TileGraph) NodeExists(n graph.Node) bool
- func (g *TileGraph) NodeList() []graph.Node
- func (g *TileGraph) PathString(path []graph.Node) string
- func (g *TileGraph) SetPassability(row, col int, passability bool)
- func (g *TileGraph) String() string
- type WeightedEdge
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DenseGraph ¶
type DenseGraph struct {
// contains filtered or unexported fields
}
A dense graph is a graph such that all IDs are in a contiguous block from 0 to TheNumberOfNodes-1. It uses an adjacency matrix and should be relatively fast for both access and writing.
This graph implements the CrunchGraph, but since it's naturally dense this is superfluous.
func NewDenseGraph ¶
func NewDenseGraph(numNodes int, passable bool) *DenseGraph
Creates a dense graph with the proper number of nodes. If passable is true all nodes will have an edge with unit cost, otherwise every node will start unconnected (cost of +Inf).
func (*DenseGraph) Crunch ¶
func (g *DenseGraph) Crunch()
DenseGraph is naturally dense, we don't need to do anything
func (*DenseGraph) DirectedEdgeList ¶
func (g *DenseGraph) DirectedEdgeList() []graph.Edge
func (*DenseGraph) EdgeBetween ¶
func (g *DenseGraph) EdgeBetween(n, neighbor graph.Node) graph.Edge
func (*DenseGraph) NodeExists ¶
func (g *DenseGraph) NodeExists(n graph.Node) bool
func (*DenseGraph) NodeList ¶
func (g *DenseGraph) NodeList() []graph.Node
func (*DenseGraph) Predecessors ¶
func (g *DenseGraph) Predecessors(n graph.Node) []graph.Node
func (*DenseGraph) RemoveEdge ¶
func (g *DenseGraph) RemoveEdge(e graph.Edge, directed bool)
Equivalent to SetEdgeCost(edge, math.Inf(1), directed)
func (*DenseGraph) SetEdgeCost ¶
func (g *DenseGraph) SetEdgeCost(e graph.Edge, cost float64, directed bool)
Sets the cost of an edge. If the cost is +Inf, it will remove the edge, if directed is true, it will only remove the edge one way. If it's false it will change the cost of the edge from succ to node as well.
func (*DenseGraph) Successors ¶
func (g *DenseGraph) Successors(n graph.Node) []graph.Node
type DirectedGraph ¶
type DirectedGraph struct {
// contains filtered or unexported fields
}
A Directed graph is a highly generalized MutableDirectedGraph.
In most cases it's likely more desireable to use a graph specific to your problem domain.
func NewDirectedGraph ¶
func NewDirectedGraph() *DirectedGraph
func (*DirectedGraph) AddDirectedEdge ¶
func (g *DirectedGraph) AddDirectedEdge(e graph.Edge, cost float64)
func (*DirectedGraph) AddNode ¶
func (g *DirectedGraph) AddNode(n graph.Node)
Adds a node to the graph. Implementation note: if you add a node close to or at the max int on your machine NewNode will become slower.
func (*DirectedGraph) EdgeBetween ¶
func (g *DirectedGraph) EdgeBetween(n, neigh graph.Node) graph.Edge
func (*DirectedGraph) EdgeList ¶
func (g *DirectedGraph) EdgeList() []graph.Edge
func (*DirectedGraph) EmptyGraph ¶
func (g *DirectedGraph) EmptyGraph()
func (*DirectedGraph) NewNode ¶
func (g *DirectedGraph) NewNode() graph.Node
func (*DirectedGraph) NodeExists ¶
func (g *DirectedGraph) NodeExists(n graph.Node) bool
func (*DirectedGraph) NodeList ¶
func (g *DirectedGraph) NodeList() []graph.Node
func (*DirectedGraph) Predecessors ¶
func (g *DirectedGraph) Predecessors(n graph.Node) []graph.Node
func (*DirectedGraph) RemoveDirectedEdge ¶
func (g *DirectedGraph) RemoveDirectedEdge(e graph.Edge)
func (*DirectedGraph) RemoveNode ¶
func (g *DirectedGraph) RemoveNode(n graph.Node)
func (*DirectedGraph) Successors ¶
func (g *DirectedGraph) Successors(n graph.Node) []graph.Node
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
A GonumGraph is a very generalized graph that can handle an arbitrary number of vertices and edges -- as well as act as either directed or undirected.
Internally, it uses a map of successors AND predecessors, to speed up some operations (such as getting all successors/predecessors). It also speeds up things like adding edges (assuming both edges exist).
However, its generality is also its weakness (and partially a flaw in needing to satisfy MutableGraph). For most purposes, creating your own graph is probably better. For instance, see TileGraph for an example of an immutable 2D grid of tiles that also implements the Graph interface, but would be more suitable if all you needed was a simple undirected 2D grid.
func (*Graph) EmptyGraph ¶
func (g *Graph) EmptyGraph()
func (*Graph) RemoveNode ¶
func (*Graph) RemoveUndirectedEdge ¶
type TileGraph ¶
type TileGraph struct {
// contains filtered or unexported fields
}