Class NfaExecutionUtils
java.lang.Object
org.aksw.jena_sparql_api.sparql_path2.NfaExecutionUtils
- Type Parameters:
S- NFA State typeT- NFA Transition typeV- Data Vertex Type (e.g. jena's Node or RDFNode)E- Data Property Edge Type (e.g. jena's Node or Property)
- Author:
- raven
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <S,T, G, V, E>
NfaFrontier<S,G, V, E> advanceFrontier(NfaFrontier<S, G, V, E> frontier, org.jgrapht.Graph<S, T> nfaGraph, Predicate<T> isEpsilon, TripletLookup<T, G, V, E> getMatchingTriplets, Function<NestedPath<V, E>, G> pathGrouper, Predicate<NestedPath<V, E>> earlyPathReject) The getMatchingTriples function takes as input all paths (by some grouping) for a certain nfa state, and yields a set of triplets that connect to the endpoints of the current paths in that groupstatic <S,T, G, V, E>
booleancollectPaths(Nfa<S, T> nfa, NfaFrontier<S, G, V, E> frontier, Predicate<T> isEpsilon, Predicate<NestedPath<V, E>> pathFilter, Function<NestedPath<V, E>, Boolean> pathCallback) static <S,T, G, V, E>
voidexecuteNfa(Nfa<S, T> nfa, Set<S> startStates, Predicate<T> isEpsilon, Set<V> startVertices, Function<NestedPath<V, E>, G> pathGrouper, TripletLookup<T, G, V, E> getMatchingTriplets, Function<NestedPath<V, E>, Boolean> pathCallback) Generic Nfa executionstatic <S,D, T extends LabeledEdge<S, ? extends org.aksw.commons.util.Directed<? extends ValueSet<D>>>>
Pair<ValueSet<D>>extractNextPropertyClasses(org.jgrapht.Graph<S, T> nfaGraph, Predicate<T> isEpsilon, Set<S> states, boolean reverse) static <S,T, P, Q> List<NestedPath<P, Q>> findPathsInJoinSummary(Nfa<S, T> nfa, Predicate<T> isEpsilon, Set<S> states, org.jgrapht.Graph<P, Q> joinGraph, P startVertex, Long k, BiFunction<T, P, Set<org.aksw.commons.util.Directed<P>>> initPred, BiFunction<T, org.aksw.commons.util.Directed<P>, Set<org.aksw.commons.util.Directed<P>>> transAndNodesToTriplets, Function<NestedPath<P, Q>, Boolean> pathCallback) matcher(Directed, joinGraph, vertex) static <S,T> boolean isFinalState(Nfa<S, T> nfa, S state, Predicate<T> isEpsilon) Tests if a state is final.static booleanCheck whether the latest contribution (the last vertex) is already part of the path.static <S,T> boolean isStartState(Nfa<S, T> nfa, S state, Predicate<T> isEpsilon) static <S,T, P, Q> boolean isTargetReachable(Nfa<S, T> nfa, Predicate<T> isEpsilon, Set<S> states, BiPredicate<org.aksw.commons.util.Directed<T>, Q> matcher, org.jgrapht.Graph<P, Q> joinGraph, org.aksw.commons.util.Directed<P> diPredicate, Pair<Set<P>> targetPreds) Given - an nfa and - join graph, determine for a given - predicate (pointing either forwards or backwards) in a certain set of //nestedPath in a certain set of - nfa states of whether it can reach the - set of predicates leading to the target states.
-
Constructor Details
-
NfaExecutionUtils
public NfaExecutionUtils()
-
-
Method Details
-
collectPaths
public static <S,T, boolean collectPathsG, V, E> (Nfa<S, T> nfa, NfaFrontier<S, G, V, E> frontier, Predicate<T> isEpsilon, Predicate<NestedPath<V, E>> pathFilter, Function<NestedPath<V, E>, Boolean> pathCallback) -
extractNextPropertyClasses
-
advanceFrontier
public static <S,T, NfaFrontier<S,G, V, E> G, advanceFrontierV, E> (NfaFrontier<S, G, V, E> frontier, org.jgrapht.Graph<S, T> nfaGraph, Predicate<T> isEpsilon, TripletLookup<T, G, V, E> getMatchingTriplets, Function<NestedPath<V, E>, G> pathGrouper, Predicate<NestedPath<V, E>> earlyPathReject) The getMatchingTriples function takes as input all paths (by some grouping) for a certain nfa state, and yields a set of triplets that connect to the endpoints of the current paths in that group- Parameters:
frontier-nfaGraph-isEpsilon-getMatchingTriplets-pathGrouper-earlyPathReject-- Returns:
-
isFinalState
Tests if a state is final. This includes if there is a transitive connection via epsilon edges to a final state.- Parameters:
state-- Returns:
-
isStartState
-
isTargetReachable
public static <S,T, boolean isTargetReachableP, Q> (Nfa<S, T> nfa, Predicate<T> isEpsilon, Set<S> states, BiPredicate<org.aksw.commons.util.Directed<T>, Q> matcher, org.jgrapht.Graph<P, Q> joinGraph, org.aksw.commons.util.Directed<P> diPredicate, Pair<Set<P>> targetPreds) Given - an nfa and - join graph, determine for a given - predicate (pointing either forwards or backwards) in a certain set of //nestedPath in a certain set of - nfa states of whether it can reach the - set of predicates leading to the target states. Execution works as follows: It is assumed that the given predicate is reachable, so no further checks are performed. BiFunction<Set, Directed , Map<V, Set<Triplet<V, E>>>> getMatchingTriplets -
findPathsInJoinSummary
public static <S,T, List<NestedPath<P,P, Q> Q>> findPathsInJoinSummary(Nfa<S, T> nfa, Predicate<T> isEpsilon, Set<S> states, org.jgrapht.Graph<P, Q> joinGraph, P startVertex, Long k, BiFunction<T, P, Set<org.aksw.commons.util.Directed<P>>> initPred, BiFunction<T, org.aksw.commons.util.Directed<P>, Set<org.aksw.commons.util.Directed<P>>> transAndNodesToTriplets, Function<NestedPath<P, Q>, Boolean> pathCallback) matcher(Directed, joinGraph, vertex) - Parameters:
nfa-isEpsilon-states-matcher-joinGraph-diPredicate-targetPreds-- Returns:
-
isLastVertexAlreadyContained
Check whether the latest contribution (the last vertex) is already part of the path. No other vertices are checked for uniqueness. -
executeNfa
public static <S,T, void executeNfaG, V, E> (Nfa<S, T> nfa, Set<S> startStates, Predicate<T> isEpsilon, Set<V> startVertices, Function<NestedPath<V, E>, G> pathGrouper, TripletLookup<T, G, V, E> getMatchingTriplets, Function<NestedPath<V, E>, Boolean> pathCallback) Generic Nfa execution- Parameters:
nfa-startStates-isEpsilon-startVertices-pathGrouper-getMatchingTriplets-pathCallback-
-