Skip to content

Graphs

jaxscape.graph.AbstractGraph ¤

Abstract base class for graphs.

jaxscape.graph.Graph ¤

A simple graph defined by an adjacency matrix.

Arguments:

  • adjacency_matrix: A jax.experimental.sparse.BCOO adjacency matrix.
get_adjacency_matrix() -> BCOO ¤

jaxscape.graph.GridGraph ¤

Grid graph where vertices are defined by a rectangular grid.

Arguments:

  • grid is a 2D array of shape (height, width) used to define edge weights. When calculating distances, edge weights are assume to represent permeability (i.e., 1/resistance, higher values indicate easier movement).
  • fun is a function applied to the source and target node values to define the edge weight. It takes two arrays and returns an array of the same size. Defaults to assigning the target vertex weight (fun = lambda x, y: y).
  • neighbors defines the contiguity pattern, and can be either ROOK_CONTIGUITY or QUEEN_CONTIGUITY.
coord_to_index(i: Array, j: Array) -> Array ¤

Convert (i, j) grid coordinates to the associated passive vertex index.

index_to_coord(v: Array) -> Array ¤

Convert passive vertex index v to (i, j) grid coordinates.

node_values_to_array(values: Array) -> Array ¤

Reshapes the 1D array values of vertices to the underlying 2D grid.

array_to_node_values(array: Array) -> Array ¤

Reshapes the 1D array values of vertices to the underlying 2D grid.