Skip to content

Commit

Permalink
entity: expose organizer's adjacency matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
cjhowedev committed Sep 20, 2023
1 parent 6ee64d1 commit 2a93073
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/entt/entity/organizer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,10 +378,25 @@ class basic_organizer final {
* @return The adjacency list of the task graph.
*/
std::vector<vertex> graph() {
return build_list(build_matrix());
}

/**
* @brief Builds an adjacency matrix for the current content.
* @return The adjacency matrix for the task graph
*/
entt::adjacency_matrix<entt::directed_tag> build_matrix() {
return builder.graph();
}

/**
* @brief Builds an adjacency list for the given adjacency matrix.
* @param matrix The adjacency matrix for the task graph
* @return The adjacency list for the task graph
*/
std::vector<vertex> build_list(const entt::adjacency_matrix<entt::directed_tag> &matrix) {
std::vector<vertex> adjacency_list{};
adjacency_list.reserve(vertices.size());
auto adjacency_matrix = builder.graph();

for(auto curr: adjacency_matrix.vertices()) {
const auto iterable = adjacency_matrix.in_edges(curr);
std::vector<std::size_t> reachable{};
Expand All @@ -397,7 +412,8 @@ class basic_organizer final {
}

/*! @brief Erases all elements from a container. */
void clear() {
void
clear() {
builder.clear();
vertices.clear();
}
Expand Down

0 comments on commit 2a93073

Please sign in to comment.