pysdic.Mesh.compute_vertices_adjacency_matrix#
- Mesh.compute_vertices_adjacency_matrix(max_distance=None, precompute=False)[source]#
Compute the vertices path distance matrix (adjacency matrix) from the connectivity of the mesh.
The distance between two vertices is defined as the minimum number of elements that must be traversed to go from one vertex to another. The output is a symmetric square matrix of shape (\(N_v\), \(N_v\)), where \(N_v\) is the number of vertices.
Note
The method is a convenience wrapper around the
pysdic.compute_vertices_adjacency_matrix()function, which computes the vertices adjacency matrix using a breadth-first search (BFS) algorithm for each vertex in the mesh.Warning
The same object returned by this method is stored in the precomputed properties of the mesh with the key ‘vertices_adjacency_matrix’ if
precomputeis set toTrue. Please be cautious when modifying the returned adjacency matrix, as it will affect the value stored in the precomputed properties of the mesh.- Parameters:
max_distance (Optional[Integral], optional) – The maximum distance to consider between vertices. If the distance between two vertices exceeds this value, the corresponding entry in the adjacency matrix will be set to -1. If
None, there is no maximum distance and all distances will be computed. By defaultNone.precompute (
bool, optional) – IfTrue, the computed vertices adjacency matrix will be stored in the precomputed properties of the mesh with the key ‘vertices_adjacency_matrix’. IfFalse, the computed vertices adjacency matrix will not be stored in the precomputed properties of the mesh. By defaultFalse.
- Returns:
A square array of shape (\(N_v\), \(N_v\)) representing the path distance matrix between vertices.
- Return type:
See also
pysdic.compute_vertices_adjacency_matrix()For more information on the algorithm used to compute the vertices adjacency matrix and an example of the output format.