Class DefaultTopologicalOrderGraph
java.lang.Object
ai.timefold.solver.core.impl.domain.variable.declarative.DefaultTopologicalOrderGraph
- All Implemented Interfaces:
BaseTopologicalOrderGraph,TopologicalOrderGraph
-
Nested Class Summary
Nested classes/interfaces inherited from interface ai.timefold.solver.core.impl.domain.variable.declarative.BaseTopologicalOrderGraph
BaseTopologicalOrderGraph.NodeTopologicalOrderNested classes/interfaces inherited from interface ai.timefold.solver.core.impl.domain.variable.declarative.TopologicalOrderGraph
TopologicalOrderGraph.EdgeConsumer -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEdge(int fromNode, int toNode) Called when a graph edge is added.voidcommitChanges(BitSet changed) Called when all edge modifications are queued.voidforEachEdge(TopologicalOrderGraph.EdgeConsumer edgeConsumer) getTopologicalOrder(int node) Returns a tuple containing node ID and a number corresponding to its topological order.booleanisLooped(LoopedTracker loopedTracker, int node) Returns true if a given node is in a strongly connected component with a size greater than 1 (i.e. is in a loop) or is a transitive successor of a node with the above property.nodeForwardEdges(int fromNode) Return an iterator of the nodes that have the `from` node as a predecessor.voidremoveEdge(int fromNode, int toNode) Called when a graph edge is removed.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ai.timefold.solver.core.impl.domain.variable.declarative.TopologicalOrderGraph
withNodeData
-
Constructor Details
-
DefaultTopologicalOrderGraph
public DefaultTopologicalOrderGraph(int size)
-
-
Method Details
-
addEdge
public void addEdge(int fromNode, int toNode) Description copied from interface:TopologicalOrderGraphCalled when a graph edge is added. The operation is added to a batch and only executed whenTopologicalOrderGraph.commitChanges(BitSet)is called.BaseTopologicalOrderGraph.getTopologicalOrder(int)is allowed to be invalid when this method returns.- Specified by:
addEdgein interfaceTopologicalOrderGraph
-
removeEdge
public void removeEdge(int fromNode, int toNode) Description copied from interface:TopologicalOrderGraphCalled when a graph edge is removed. The operation is added to a batch and only executed whenTopologicalOrderGraph.commitChanges(BitSet)is called.BaseTopologicalOrderGraph.getTopologicalOrder(int)is allowed to be invalid when this method returns.- Specified by:
removeEdgein interfaceTopologicalOrderGraph
-
forEachEdge
- Specified by:
forEachEdgein interfaceTopologicalOrderGraph
-
nodeForwardEdges
Description copied from interface:BaseTopologicalOrderGraphReturn an iterator of the nodes that have the `from` node as a predecessor.- Specified by:
nodeForwardEdgesin interfaceBaseTopologicalOrderGraph- Parameters:
fromNode- The predecessor node.- Returns:
- an iterator of nodes with from as a predecessor.
-
isLooped
Description copied from interface:BaseTopologicalOrderGraphReturns true if a given node is in a strongly connected component with a size greater than 1 (i.e. is in a loop) or is a transitive successor of a node with the above property.- Specified by:
isLoopedin interfaceBaseTopologicalOrderGraph- Parameters:
loopedTracker- a tracker that can be used to record looped state to avoid recomputation.node- The node being queried- Returns:
- true if `node` is in a loop, false otherwise.
-
getTopologicalOrder
Description copied from interface:BaseTopologicalOrderGraphReturns a tuple containing node ID and a number corresponding to its topological order. In particular, afterTopologicalOrderGraph.commitChanges(java.util.BitSet)is called, the following must be true for any pair of nodes A, B where:- A is a predecessor of B
- `isLooped(A) == isLooped(B) == false`
Said number may not be unique.
- Specified by:
getTopologicalOrderin interfaceBaseTopologicalOrderGraph
-
commitChanges
Description copied from interface:TopologicalOrderGraphCalled when all edge modifications are queued. After this method returns,BaseTopologicalOrderGraph.getTopologicalOrder(int)must be accurate for every node in the graph.- Specified by:
commitChangesin interfaceTopologicalOrderGraph
-
toString
-