public static int countReverseLinks(Iterable<? extends Path> paths) { int result = (int)Streams.stream(paths) .filter(p -> p instanceof P_Path0 ? !((P_Path0)p).isForward() : false) .count(); return result; }
public static int countForwardLinks(Iterable<? extends Path> paths) { int result = (int)Streams.stream(paths) .filter(p -> p instanceof P_Path0 ? ((P_Path0)p).isForward() : false) .count(); return result; }
public void add(P_Path0 p) { nodes.add(p) ; if ( p.isForward() ) forwardNodes.add(p.getNode()) ; else backwardNodes.add(p.getNode()) ; }
public static List<Triple> pathToTriples(SimplePath path, Var start, Var end, Generator<Var> generator) { List<Triple> result = new ArrayList<Triple>(); Var a = start; Iterator<P_Path0> it = path.getSteps().iterator(); while(it.hasNext()) { P_Path0 step = it.next(); Var b; if(it.hasNext()) { b = generator.next();//Var.alloc(generator.next()); } else { b = end; } Triple t; if(step.isForward()) { t = new Triple(a, step.getNode(), b); } else { t = new Triple(b, step.getNode(), a); } result.add(t); a = b; } return result; }
private void output(P_Path0 path0) { if ( !path0.isForward() ) out.print("^") ; out.print(FmtUtils.stringForNode(path0.getNode(), prologue)) ; }
if ( p.isForward() ) forwards.add(p) ; else
boolean isFwd = step.isForward();
public static boolean matchesStep(PredicateClass pclass, P_Path0 step) { boolean result = step.isForward() ? pclass.getFwdNodes().contains(step.getNode()) : pclass.getBwdNodes().contains(step.getNode()); return result; }
public static PredicateClass toPredicateClass(P_Path0 path) { ValueSet<Node> f; ValueSet<Node> b; if(path.isForward()) { f = ValueSet.create(true, path.getNode()); b = ValueSet.create(true); } else { f = ValueSet.create(true); b = ValueSet.create(true, path.getNode()); } PredicateClass result = new PredicateClass(f, b); return result; }