Class BackwardFixpoint<G extends Graph<G,N,E>,N extends Node<G,N,E>,E extends Edge<G,N,E>,T>
- java.lang.Object
-
- it.unive.lisa.util.datastructures.graph.algorithms.BackwardFixpoint<G,N,E,T>
-
- Type Parameters:
G
- the type of the sourceGraph
N
- the type of theNode
s in the source graphE
- the type of theEdge
s in the source graphT
- the type of data computed by the fixpoint
- Direct Known Subclasses:
OptimizedBackwardFixpoint
public class BackwardFixpoint<G extends Graph<G,N,E>,N extends Node<G,N,E>,E extends Edge<G,N,E>,T> extends java.lang.Object
A backward fixpoint algorithm for aGraph
, parametric to theFixpoint.FixpointImplementation
that one wants to use to compute the results.
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.String
ERROR
Common format for error messages.protected boolean
forceFullEvaluation
Whether or not all nodes should be processed at least once.protected G
graph
The graph to target.
-
Constructor Summary
Constructors Constructor Description BackwardFixpoint(G graph, boolean forceFullEvaluation)
Builds a fixpoint for the givenGraph
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Map<N,T>
fixpoint(java.util.Map<N,T> startingPoints, WorkingSet<N> ws, Fixpoint.FixpointImplementation<N,E,T> implementation)
Runs the fixpoint.java.util.Map<N,T>
fixpoint(java.util.Map<N,T> startingPoints, WorkingSet<N> ws, Fixpoint.FixpointImplementation<N,E,T> implementation, java.util.Map<N,T> initialResult)
Runs the fixpoint.protected T
getExitState(N node, T startstate, Fixpoint.FixpointImplementation<N,E,T> implementation, java.util.Map<N,T> result)
Yields the exit state for the given node.
-
-
-
Field Detail
-
ERROR
protected static final java.lang.String ERROR
Common format for error messages.- See Also:
- Constant Field Values
-
forceFullEvaluation
protected final boolean forceFullEvaluation
Whether or not all nodes should be processed at least once.
-
-
Method Detail
-
fixpoint
public java.util.Map<N,T> fixpoint(java.util.Map<N,T> startingPoints, WorkingSet<N> ws, Fixpoint.FixpointImplementation<N,E,T> implementation) throws FixpointException
Runs the fixpoint. Invoking this method effectively recomputes the result: no caching on previous runs is executed. It starts with empty result.- Parameters:
startingPoints
- a map containing all the nodes to start the fixpoint at, each mapped to its entry state.ws
- the instance ofWorkingSet
to use for the fixpointimplementation
- theFixpoint.FixpointImplementation
to use for running the fixpoint- Returns:
- a mapping from each (reachable) node of the source graph to the fixpoint result computed at that node
- Throws:
FixpointException
- if something goes wrong during the fixpoint execution
-
fixpoint
public java.util.Map<N,T> fixpoint(java.util.Map<N,T> startingPoints, WorkingSet<N> ws, Fixpoint.FixpointImplementation<N,E,T> implementation, java.util.Map<N,T> initialResult) throws FixpointException
Runs the fixpoint. Invoking this method effectively recomputes the result: no caching on previous runs is executed.- Parameters:
startingPoints
- a map containing all the nodes to start the fixpoint at, each mapped to its entry state.ws
- the instance ofWorkingSet
to use for the fixpointimplementation
- theFixpoint.FixpointImplementation
to use for running the fixpointinitialResult
- the map of initial result to use for running the fixpoint- Returns:
- a mapping from each (reachable) node of the source graph to the fixpoint result computed at that node
- Throws:
FixpointException
- if something goes wrong during the fixpoint execution
-
getExitState
protected T getExitState(N node, T startstate, Fixpoint.FixpointImplementation<N,E,T> implementation, java.util.Map<N,T> result) throws FixpointException
Yields the exit state for the given node.- Parameters:
node
- the node under evaluationstartstate
- a predefined ending state that must be taken into account for the computationimplementation
- the fixpoint implementation that knows how to combine different statesresult
- the current approximations for each node- Returns:
- the computed state
- Throws:
FixpointException
- if something goes wrong during the computation
-
-