Skip to content
2 changes: 1 addition & 1 deletion python/dolfinx/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def compute_colliding_cells(


def squared_distance(
mesh: Mesh, dim: int, entities: list[int], points: npt.NDArray[np.floating]
mesh: Mesh, dim: int, entities: npt.NDArray[np.int32], points: npt.NDArray[np.floating]
) -> npt.NDArray[np.floating]:
"""Compute the squared distance between a point and a mesh entity.

Expand Down
31 changes: 31 additions & 0 deletions python/dolfinx/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,52 @@ class AdjacencyList:
_cpp_object: Union[_cpp.la.AdjacencyList_int32, _cpp.la.AdjacencyList_int64]
Comment thread
schnellerhase marked this conversation as resolved.

def __init__(self, cpp_object: Union[_cpp.la.AdjacencyList_int32, _cpp.la.AdjacencyList_int64]):
"""Creates a python wrapper for the exported adjacency list class.
Comment thread
schnellerhase marked this conversation as resolved.
Outdated

Note:
This constructor does not create a new adjacency list, see `adjacencylist` for that.
Comment thread
schnellerhase marked this conversation as resolved.
Outdated

Args:
The underlying cpp instance that this object will wrap.
"""
self._cpp_object = cpp_object

def links(self, node: Union[np.int32, np.int64]) -> npt.NDArray[Union[np.int32, np.int64]]:
"""Retrieve the links of a node.

Args:
Node to retrieve the connectitivty of.

Returns:
Neighbors of the node.
"""
return self._cpp_object.links(node)

@property
def array(self) -> npt.NDArray[Union[np.int32, np.int64]]:
"""Array representation of the adjacency list.

Returns:
Flattened array representation of the adjacency list.
"""
return self._cpp_object.array

@property
def offsets(self) -> npt.NDArray[np.int32]:
"""Offsets for each node in the `array()`.
Comment thread
schnellerhase marked this conversation as resolved.
Outdated

Returns:
Array of indices with shape `(num_nodes+1)`.
"""
return self._cpp_object.offsets

@property
def num_nodes(self) -> np.int32:
"""Number of nodes in the adjacency list.

Returns:
Number of nodes.
"""
return self._cpp_object.num_nodes


Expand Down