udm.core#
Attributes#
Classes#
A class representing the constant 1 for unweighted graphs. |
|
Abstract base class for all cell types. |
|
A simple cell implementation. |
|
A node in a grid graph with a location and weight. |
|
A graph embedded in a 2D grid with a unit disk connectivity radius. |
Module Contents#
- SHOW_WEIGHT = False#
- class UNWEIGHTED#
A class representing the constant 1 for unweighted graphs.
- UNWEIGHTED_INSTANCE#
- class AbstractCell(occupied: bool = True, weight: Any = UNWEIGHTED_INSTANCE)#
Abstract base class for all cell types.
- occupied = True#
- weight#
- format_cell(show_weight: bool = False) str #
Format cell for display.
- property is_empty: bool#
Check if cell is empty.
- get_weight()#
Get the weight of the cell.
- class SimpleCell(occupied: bool = True, weight: Any = UNWEIGHTED_INSTANCE)#
Bases:
AbstractCell
A simple cell implementation.
- classmethod create_empty(weight_type=UNWEIGHTED)#
Create an empty cell of a given weight type.
- WeightedSimpleCell#
- UnWeightedSimpleCell#
- class Node(*args, **kwargs)#
A node in a grid graph with a location and weight.
- get_xy()#
Get the location as a tuple.
- change_xy(new_loc)#
Create a new node with the same weight but different location.
- offset(xy_offset)#
Create a new node offset by the given amount.
- WeightedNode#
- UnWeightedNode#
- class GridGraph(size, nodes, radius)#
A graph embedded in a 2D grid with a unit disk connectivity radius.
Initialize a GridGraph.
- Parameters:
size – Tuple of (height, width) of the grid
nodes – List of Node objects
radius – The radius for determining connectivity in the unit disk graph
- size#
- nodes#
- radius#
- get_size()#
Get the size of the grid.
- get_graph_and_weights()#
Get the graph and weights as separate objects.
- to_networkx()#
Convert to a NetworkX graph.
- get_coordinates()#
Get all node coordinates.
- neighbors(i)#
Get neighbors of node i based on the unit disk distance.
- static distance(n1, n2)#
Calculate Euclidean distance between two nodes.
- num_vertices()#
Get the number of vertices in the graph.
- vertices()#
Get all vertex indices.
- cell_matrix()#
Convert the grid graph to a matrix of cells.
- classmethod from_cell_matrix(matrix, radius)#
Create a GridGraph from a matrix of cells.