Exemplo n.º 1
0
  /**
   * The remote vertex is scheduled for activation unless it has already been visited.
   *
   * <p>Note: We are scattering to out-edges. Therefore, this vertex is {@link
   * Statement#getSubject()}. The remote vertex is {@link Statement#getObject()}.
   */
  @Override
  public void scatter(
      final IGASState<PATHS.VS, PATHS.ES, Void> state,
      final IGASScheduler sch,
      final Value u,
      final Statement e) {

    // remote vertex state.
    final Value v = state.getOtherVertex(u, e);

    final VS otherState = state.getState(v);

    final int otherDepth = otherState.depth();
    //        final VS otherState = state.getState(e.getObject()/* v */);

    // visit.

    if (otherState.visit(state.round() + 1, u /* predecessor */, e.getPredicate())) {

      /*
       * This is the first visit for the remote vertex. Add it to the
       * schedule for the next iteration.
       */

      sch.schedule(v);
    }
  }
Exemplo n.º 2
0
  /*
   * TODO Do this in parallel for each specified target vertex.
   */
  @Override
  public void prunePaths(final IGASContext<VS, ES, Void> ctx, final Value[] targetVertices) {

    //    	if(true)
    //    	return;

    if (ctx == null) throw new IllegalArgumentException();

    if (targetVertices == null) throw new IllegalArgumentException();

    final IGASState<PATHS.VS, PATHS.ES, Void> gasState = ctx.getGASState();

    final Set<Value> retainSet = new HashSet<Value>();

    for (Value v : targetVertices) {

      if (!gasState.isVisited(v)) {

        // This target was not reachable.
        continue;
      }

      /*
       * Walk the precessors back to a starting vertex.
       */
      retainSet.add(v);

      visitPredecessors(gasState, v, retainSet);
    } // next target vertex.

    gasState.retainAll(retainSet);
  }
Exemplo n.º 3
0
  /** Not used. */
  @Override
  public void initVertex(
      final IGASContext<PATHS.VS, PATHS.ES, Void> ctx,
      final IGASState<PATHS.VS, PATHS.ES, Void> state,
      final Value u) {

    state.getState(u).visit(0, null /* predecessor */, null /* edge */);
  }
Exemplo n.º 4
0
  protected void visitPredecessors(
      final IGASState<PATHS.VS, PATHS.ES, Void> gasState,
      final Value v,
      final Set<Value> retainSet) {

    final PATHS.VS currentState = gasState.getState(v);

    //    	final int curDepth = currentState.depth.get();

    for (Value pred : currentState.predecessors().keySet()) {

      //        	if (pred == null) {
      //
      //        		continue;
      //
      //        	}

      //        	if (retainSet.contains(pred)) {
      //
      //        		continue;
      //
      //        	}

      //        	final int predDepth = gasState.getState(pred).depth.get();
      //
      //        	if (predDepth >= curDepth) {
      //
      //        		continue;
      //
      //        	}

      if (!retainSet.contains(pred)) {

        retainSet.add(pred);

        visitPredecessors(gasState, pred, retainSet);
      }
    }
  }