Ref: https://github.com/FEniCS/dolfinx/blob/e952664b086f6c7e7662c53ec54e8d774b101de4/cpp/dolfinx/fem/DofMap.cpp#L134-L173 One could then restrict the adjacency-list after creation. Would reduce the amount of extra code in the library. Should be profiled.