API reference

Docs

GridGraphs.GridDirectionType
GridDirection

Enum type for the 9 possible move directions on a 2-dimensional grid with square cells: northwest, west, southwest, north, center, south, northeast, east, southeast.

Various subsets of these directions are defined as constants, but not exported. They are based on an analogy with the game of chess:

  • QUEEN_DIRECTIONS_PLUS_CENTER
  • ROOK_DIRECTIONS_PLUS_CENTER
  • QUEEN_DIRECTIONS
  • ROOK_DIRECTIONS
  • QUEEN_ACYCLIC_DIRECTIONS
  • ROOK_ACYCLIC_DIRECTIONS

Acyclic direction sets give rise to an acyclic graph because they are contained in {south, east, southeast}.

source
GridGraphs.GridGraphType
GridGraph{
    T<:Integer,
    R<:Real,
    W<:AbstractMatrix{R},
    A<:AbstractMatrix{Bool}
}

Graph defined by a grid of vertices with index type T.

Fields

  • weights::W: vertex weights matrix, which serve to define edge weights.
  • active::A: vertex activity matrix. All the vertices on the grid exist, but only active vertices can have edges (inactive vertices are isolated).
  • directions::Vector{GridDirection}: the set of legal directions which are used to define edges.
  • diag_through_corner::Bool: defines how the weight of a diagonal edge is computed.

See also

source
GridGraphs.GridGraphMethod
GridGraph{T}(weights[; active, directions, diag_through_corner])

User-friendly constructor. By default, all vertices are active, all directions are allowed, and edge weights are always computed based on the arrival vertex alone.

source
GridGraphs.ShortestPathTreeType
ShortestPathTree{T<:Integer,R<:Real}

Storage for the result of a single-source shortest paths query with source s.

Fields

  • parents::Vector{T}: the parent of each vertex v in a shortest s -> v path.
  • dists::Vector{R}: the distance of each vertex v from s.
source
Base.:+Method
Base.+((i, j), dir)

Add a GridDirection to a couple of grid coordinates and return the new coordinates.

source
Base.:-Method
Base.-(dir)

Compute the opposite GridDirection (e.g. northwest / southeast).

source
Base.:-Method
Base.-((i, j), dir)

Subtract a GridDirection from a couple of grid coordinates and return the new coordinates.

source
Base.showMethod
Base.show(io, g)

Display a GridGraph using braille patterns when not all vertices are active.

source
Graphs.weightsMethod
Graphs.weights(g)

Efficiently compute a sparse matrix of edge weights based on the vertex weights.

source
GridGraphs.get_tupleMethod
get_tuple(::Type{T}, dir)

Translate a GridDirection into a couple of grid steps in {±1,0} with integer type T.

source
GridGraphs.has_negative_weightsMethod
has_negative_weights(g)

Check if any of the vertex weights are negative.

By default this check is not included in Dijkstra's algorithm to save time.

source
GridGraphs.path_to_matrixMethod
path_to_matrix(g::GridGraph, path::Vector{<:Integer})

Store the shortest s -> d path in g as an integer matrix of size height(g) * width(g), where entry (i,j) counts the number of visits to the associated vertex.

source

Index