private void ALP(Node node, Path path, Collection<Node> visited) { if ( trace ) System.out.printf("ALP node=%s\n visited=%s\n output=%s\n", node, visited, output) ; if ( visited.contains(node) ) return ; // If output is a set, then no point going on if node has been added to the results. // If output includes duplicates, more solutions are generated // "visited" is nodes on this path (see the matching .remove). if ( ! output.add(node) ) return ; visited.add(node) ; Iterator<Node> iter1 = eval(graph, node, path, forwardMode) ; // For each step, add to results and recurse. for ( ; iter1.hasNext() ; ) { Node n1 = iter1.next(); ALP(n1, path, visited) ; } visited.remove(node) ; } }
public void visit(P_FixedLength pFixedLength) { if ( pFixedLength.getCount() == 0 ) { output.add(node) ; return ; } // P_Mod(path, count, count) // One step. Iterator<Node> iter = eval(graph, node, pFixedLength.getSubPath(), forwardMode) ; long count2 = dec(pFixedLength.getCount()) ; P_FixedLength nextPath = new P_FixedLength(pFixedLength.getSubPath(), count2) ; for ( ; iter.hasNext() ; ) { Node n2 = iter.next() ; Iterator<Node> iter2 = eval(graph, n2, nextPath, forwardMode) ; fill(iter2) ; } }
if ( DEBUG ) IndentedWriter.stdout.println("ZeroOrMore: "+output) ; doZeroOrMore(pathMod.getSubPath()) ; if ( DEBUG ) IndentedWriter.stdout.println("ZeroOrMore: "+output) ; return ; long min2 = dec(min1) ; long max2 = dec(max1) ; iter2 = x.iterator() ; fill(iter2) ;
public void visit(P_NegPropSet pathNotOneOf) { // X !(:a|:b|^:c|^:d) Y = { X !(:a|:b) Y } UNION { Y !(:c|:d) X } if ( pathNotOneOf.getFwdNodes().size() > 0 ) { Iterator<Node> nodes1 = doOneExcludeForwards(pathNotOneOf.getFwdNodes()) ; fill(nodes1) ; } if ( pathNotOneOf.getBwdNodes().size() > 0 ) { Iterator<Node> nodes2 = doOneExcludeBackwards(pathNotOneOf.getBwdNodes()) ; fill(nodes2) ; } }
public void visit(P_ZeroOrMore path) { doZeroOrMore(path.getSubPath()) ; }
public void visit(P_OneOrMore path) { doOneOrMore(path.getSubPath()) ; }
private void doZeroOrMore(Path path) { if ( trace ) System.out.printf("\nZeroOrMore: %s\n", node) ; //Stack<Node> visited = new Stack<Node>() ; Set<Node> visited = new HashSet<Node>() ; ALP(node, path, visited) ; }
private void doOneOrMore(Path path) { if ( trace ) System.out.printf("\nOneOrMore: %s\n", node) ; //Stack<Node> visited = new Stack<Node>() ; Set<Node> visited = new HashSet<Node>() ; // Do one step without including. Iterator<Node> iter1 = eval(graph, node, path, forwardMode) ; for ( ; iter1.hasNext() ; ) { Node n1 = iter1.next(); if ( trace ) System.out.printf("One from %s\n visited=%s\n output=%s\n", n1, visited, output) ; ALP(n1, path, visited) ; } }
static private void eval$(Graph graph, Node node, Path p, boolean forward, Collection<Node> acc) { PathEvaluator evaluator = new PathEvaluator(graph, node, acc, forward) ; p.visit(evaluator) ; } // ----
private final Iterator<Node> doOneExcludeBackwards(List<Node> excludedNodes) { Iter<Triple> iter1 = backwardLinks(node, excludedNodes) ; Iter<Node> r1 = iter1.map(selectSubject) ; return r1 ; }