Class NfaExecutionUtils

java.lang.Object
org.aksw.jena_sparql_api.sparql_path2.NfaExecutionUtils
Type Parameters:
S - NFA State type
T - NFA Transition type
V - Data Vertex Type (e.g. jena's Node or RDFNode)
E - Data Property Edge Type (e.g. jena's Node or Property)

public class NfaExecutionUtils extends Object
Author:
raven
  • Constructor Details

    • NfaExecutionUtils

      public NfaExecutionUtils()
  • Method Details

    • collectPaths

      public static <S, T, G, V, E> boolean collectPaths(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

      public static <S, D, T extends org.aksw.commons.jena.jgrapht.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)
    • advanceFrontier

      public static <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 group
      Parameters:
      frontier -
      nfaGraph -
      isEpsilon -
      getMatchingTriplets -
      pathGrouper -
      earlyPathReject -
      Returns:
    • isFinalState

      public static <S, T> boolean isFinalState(Nfa<S,T> nfa, S state, Predicate<T> isEpsilon)
      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

      public static <S, T> boolean isStartState(Nfa<S,T> nfa, S state, Predicate<T> isEpsilon)
    • isTargetReachable

      public 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. 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, 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)
      Parameters:
      nfa -
      isEpsilon -
      states -
      matcher -
      joinGraph -
      diPredicate -
      targetPreds -
      Returns:
    • isLastVertexAlreadyContained

      public static boolean isLastVertexAlreadyContained(NestedPath<?,?> p)
      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, G, V, E> void executeNfa(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 -