Updates Transitive closure algorithm. #1509
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of changes
Updates Cedar's transitive closure computation. The algorithm is only sound when computing the transitive closure of DAGs and graphs with simple cycles. However, the updated transitive closure algorithm when combined with
enforce_dag_from_tcis sufficient for detecting cycles, even complex cycles. The implementation also uses a slightly more efficient algorithm (that does only one scan of the input graph) if one does not care to enforce that the graph is a DAG (while sound for computing the exact transitive closure of a DAG, this variant is not sufficient for detecting even simple cycles).This pull request also adds the
remove_tcthat is capable of repairing an existing graph's transitive closure when only a sub-set of the nodes within the graph need recalculated. This is used withinadd_entitiesandremove_entitiesto avoid re-computing the entire graph's transitive closure. This change addresses the feature request in issu #612Issue #612
Checklist for requesting a review
The change in this PR is (choose one, and delete the other options):
cedar-policy-core,cedar-validator, etc.)I confirm that this PR (choose one, and delete the other options):
I confirm that
cedar-spec(choose one, and delete the other options):I confirm that
docs.cedarpolicy.com(choose one, and delete the other options):