|
Jlm
|
#include <OnlineCycleDetection.hpp>

Public Member Functions | |
| OnlineCycleDetector (PointerObjectSet &set, const GetSuccessorsFunctor &GetSuccessors, const UnifyPointerObjectsFunctor &UnifyPointerObjects) | |
| void | InitializeTopologicalOrdering () |
| std::optional< PointerObjectIndex > | MaintainTopologicalOrder (PointerObjectIndex subset, PointerObjectIndex superset) |
| size_t | NumOnlineCyclesDetected () const noexcept |
| size_t | NumOnlineCycleUnifications () const noexcept |
Private Member Functions | |
| bool | HasValidTopologicalOrder () const |
| bool | ObjectIsInTopologicalOrder (PointerObjectIndex object) const |
| bool | IsTopologicalOrderIndexFilled (PointerObjectIndex topologicalIndex) const |
| bool | ComesAfter (PointerObjectIndex after, PointerObjectIndex before) const |
| void | ClearDfsState () |
Private Attributes | |
| PointerObjectSet & | Set_ |
| const GetSuccessorsFunctor & | GetSuccessors_ |
| const UnifyPointerObjectsFunctor & | UnifyPointerObjects_ |
| std::vector< PointerObjectIndex > | ObjectToTopoOrder_ |
| std::vector< PointerObjectIndex > | TopoOrderToObject_ |
| std::stack< std::pair< PointerObjectIndex, bool > > | DfsStack_ |
| util::HashSet< PointerObjectIndex > | DfsNodesVisited_ |
| util::HashSet< PointerObjectIndex > | DfsCycleNodes_ |
| std::vector< PointerObjectIndex > | DfsSupersetAndBeyond_ |
| size_t | NumOnlineCyclesDetected_ = 0 |
| size_t | NumOnlineCycleUnifications_ = 0 |
Static Private Attributes | |
| static constexpr PointerObjectIndex | EmptyTopologicalSlot |
Online Cycle Detection maintains a topological ordering of all unification roots, with respect to superset edges. If this is not possible, there must be a cycle, which gets eliminated. Online Cycle Detection can not be combined with other cycle detection schemes, but that is OK, since OCD finds every cycle.
| GetSuccessorsFunctor | is a function returning the superset edge successors of a given node |
| UnifyPointerObjectsFunctor | is a function that unifies other unification roots. |
Definition at line 27 of file OnlineCycleDetection.hpp.
|
inline |
Definition at line 31 of file OnlineCycleDetection.hpp.
|
inlineprivate |
Prepares all internal state for a new DFS
Definition at line 375 of file OnlineCycleDetection.hpp.
|
inlineprivate |
after and before both have positions in the topological index, and after comes strictly after before. Otherwise false. Definition at line 364 of file OnlineCycleDetection.hpp.
|
inlineprivate |
Function for validating that all invariants of the topological ordering are maintained. Nodes should have a position in the topological order iff they are unification roots. All successor roots should come later in the topological order. The bi-directional lookup, node <-> topological index, is maintained.
Definition at line 295 of file OnlineCycleDetection.hpp.
|
inline |
Assigns each unification root a position in a topological ordering. If any cycles are detected, they are unified. This function assumes that GetSuccessors returns only unification roots.
Definition at line 46 of file OnlineCycleDetection.hpp.
|
inlineprivate |
The topological order contains all unification roots, and only unification roots.
index in the topological order is occupied, false otherwise. Definition at line 354 of file OnlineCycleDetection.hpp.
|
inline |
Call this function after adding a superset edge subset -> superset. Both must be unification roots. If subset has a higher topological index than superset, the topological order is re-arranged. If a cycle is detected, then it will be unified away, and the unification root is returned.
| subset | the tail of the just added superset edge |
| superset | the head of the just added superset edge |
Definition at line 107 of file OnlineCycleDetection.hpp.
|
inlinenoexcept |
Definition at line 272 of file OnlineCycleDetection.hpp.
|
inlinenoexcept |
Definition at line 281 of file OnlineCycleDetection.hpp.
|
inlineprivate |
The topological order contains all unification roots, and only unification roots.
object has a position in the topological order, false otherwise. Definition at line 344 of file OnlineCycleDetection.hpp.
|
private |
Definition at line 418 of file OnlineCycleDetection.hpp.
|
private |
Definition at line 414 of file OnlineCycleDetection.hpp.
|
private |
Definition at line 411 of file OnlineCycleDetection.hpp.
|
private |
Definition at line 421 of file OnlineCycleDetection.hpp.
|
staticconstexprprivate |
Definition at line 394 of file OnlineCycleDetection.hpp.
|
private |
Definition at line 388 of file OnlineCycleDetection.hpp.
|
private |
Definition at line 424 of file OnlineCycleDetection.hpp.
|
private |
Definition at line 425 of file OnlineCycleDetection.hpp.
|
private |
Definition at line 400 of file OnlineCycleDetection.hpp.
|
private |
Definition at line 385 of file OnlineCycleDetection.hpp.
|
private |
Definition at line 404 of file OnlineCycleDetection.hpp.
|
private |
Definition at line 389 of file OnlineCycleDetection.hpp.