Documentation ¶
Index ¶
- Constants
- type Grid
- func (g *Grid) Dims() (r, c int)
- func (g *Grid) Edge(u, v graph.Node) graph.Edge
- func (g *Grid) EdgeBetween(u, v graph.Node) graph.Edge
- func (g *Grid) From(u graph.Node) []graph.Node
- func (g *Grid) Has(n graph.Node) bool
- func (g *Grid) HasEdge(u, v graph.Node) bool
- func (g *Grid) NodeAt(r, c int) graph.Node
- func (g *Grid) Nodes() []graph.Node
- func (g *Grid) Render(path []graph.Node) ([]byte, error)
- func (g *Grid) RowCol(id int) (r, c int)
- func (g *Grid) Set(r, c int, open bool)
- func (g *Grid) String() string
- func (g *Grid) Weight(e graph.Edge) float64
- func (g *Grid) XY(n graph.Node) (x, y float64)
Constants ¶
View Source
const ( Closed = '*' // Closed is the closed grid node representation. Open = '.' // Open is the open grid node repesentation. )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Grid ¶
type Grid struct { // AllowDiagonal specifies whether // diagonally adjacent nodes can // be connected by an edge. AllowDiagonal bool // contains filtered or unexported fields }
Grid is a 2D grid planar undirected graph.
func NewGridFrom ¶
NewGridFrom returns a grid specified by the rows strings. All rows must be the same length and must only contain the Open or Closed characters, NewGridFrom will panic otherwise.
func (*Grid) EdgeBetween ¶
EdgeBetween returns the edge between u and v.
func (*Grid) Render ¶
Render returns a text representation of the graph with the given path included. If the path is not a path in the grid Render returns a non-nil error and the path up to that point.
func (*Grid) RowCol ¶
RowCol returns the row and column of the id. RowCol will panic if the node id is outside the range of the grid.
Click to show internal directories.
Click to hide internal directories.