MCPcopy Create free account
hub / github.com/FEniCS/dolfinx / adjacencylist

Function adjacencylist

python/dolfinx/graph.py:122–146  ·  view source on GitHub ↗

Create an :class:`AdjacencyList` for `int32` or `int64` datasets. Args: data: The adjacency array. If the array is one-dimensional, offsets should be supplied. If the array is two-dimensional the number of edges per node is the second dimension. offsets:

(
    data: npt.NDArray[Index], offsets: npt.NDArray[np.int32] | None = None
)

Source from the content-addressed store, hash-verified

120
121
122def adjacencylist(
123 data: npt.NDArray[Index], offsets: npt.NDArray[np.int32] | None = None
124) -> AdjacencyList[Index]:
125 """Create an :class:`AdjacencyList` for `int32` or `int64` datasets.
126
127 Args:
128 data: The adjacency array. If the array is one-dimensional,
129 offsets should be supplied. If the array is two-dimensional
130 the number of edges per node is the second dimension.
131 offsets: The offsets array with the number of edges per node.
132
133 Returns:
134 An adjacency list.
135 """
136 # TODO: Switch to np.isdtype(data.dtype, np.int32) once numpy >= 2.0 is
137 # enforced
138 if data.dtype == np.int32:
139 cpp_t = _cpp.graph.AdjacencyList_int32
140 elif data.dtype == np.int64:
141 cpp_t = _cpp.graph.AdjacencyList_int64
142 else:
143 raise TypeError("Data type for adjacency list not supported.")
144
145 cpp_object = cpp_t(data, offsets) if offsets is not None else cpp_t(data)
146 return AdjacencyList(cpp_object)
147
148
149def comm_graph(map: _cpp.common.IndexMap, root: int = 0) -> AdjacencyList:

Callers 7

test_createFunction · 0.90
test_ufl_idFunction · 0.90
partitionerMethod · 0.90
test_create_adj2dFunction · 0.90
model_to_meshFunction · 0.90

Calls 1

AdjacencyListClass · 0.70

Tested by 6

test_createFunction · 0.72
test_ufl_idFunction · 0.72
partitionerMethod · 0.72
test_create_adj2dFunction · 0.72