private ManagementVertex getCandidateVertex(final TraversalEntry te, final boolean forward) {

		if (forward) {

			while (true) {

				if (this.confinedToStage && te.getCurrentChannel() == 0) {
					while (currentGateLeadsToOtherStage(te, this.forward)) {
						te.increaseCurrentGate();
					}
				}

				// No more outgoing edges to consider
				if (te.getCurrentGate() >= te.getManagementVertex().getNumberOfOutputGates()) {
					break;
				}

				if (te.getCurrentChannel() >= te.getManagementVertex().getOutputGate(te.getCurrentGate())
					.getNumberOfForwardEdges()) {
					te.increaseCurrentGate();
					te.resetCurrentChannel();
				} else {
					final ManagementEdge forwardEdge = te.getManagementVertex().getOutputGate(te.getCurrentGate())
						.getForwardEdge(te.getCurrentChannel());
					final ManagementVertex target = forwardEdge.getTarget().getVertex();
					te.increaseCurrentChannel();
					if (!alreadyVisited.contains(target)) {
						return target;
					}
				}
			}
		} else {

			while (true) {

				if (this.confinedToStage && te.getCurrentChannel() == 0) {
					while (currentGateLeadsToOtherStage(te, this.forward)) {
						te.increaseCurrentGate();
					}
				}

				// No more incoming edges to consider
				if (te.getCurrentGate() >= te.getManagementVertex().getNumberOfInputGates()) {
					break;
				}

				if (te.getCurrentChannel() >= te.getManagementVertex().getInputGate(te.getCurrentGate())
					.getNumberOfBackwardEdges()) {
					te.increaseCurrentGate();
					te.resetCurrentChannel();
				} else {
					final ManagementEdge backwardEdge = te.getManagementVertex().getInputGate(te.getCurrentGate())
						.getBackwardEdge(te.getCurrentChannel());
					final ManagementVertex source = backwardEdge.getSource().getVertex();
					if (source == null) {
						LOG.error("Inconsistency in vertex map found (backward)!");
					}
					te.increaseCurrentChannel();
					if (!this.alreadyVisited.contains(source)) {
						return source;
					}
				}
			}
		}

		return null;
	}
private ManagementVertex getCandidateVertex ( final TraversalEntry te , final boolean forward ) { if ( forward ) { while ( true ) { if ( this . confinedToStage && te . getCurrentChannel ( ) == 0 ) { while ( currentGateLeadsToOtherStage ( te , this . forward ) ) { te . increaseCurrentGate ( ) ; } } if ( te . getCurrentGate ( ) >= te . getManagementVertex ( ) . getNumberOfOutputGates ( ) ) { break ; } if ( te . getCurrentChannel ( ) >= te . getManagementVertex ( ) . getOutputGate ( te . getCurrentGate ( ) ) . getNumberOfForwardEdges ( ) ) { te . increaseCurrentGate ( ) ; te . resetCurrentChannel ( ) ; } else { final ManagementEdge forwardEdge = te . getManagementVertex ( ) . getOutputGate ( te . getCurrentGate ( ) ) . getForwardEdge ( te . getCurrentChannel ( ) ) ; final ManagementVertex target = forwardEdge . getTarget ( ) . getVertex ( ) ; te . increaseCurrentChannel ( ) ; if ( ! alreadyVisited . contains ( target ) ) { return target ; } } } } else { while ( true ) { if ( this . confinedToStage && te . getCurrentChannel ( ) == 0 ) { while ( currentGateLeadsToOtherStage ( te , this . forward ) ) { te . increaseCurrentGate ( ) ; } } if ( te . getCurrentGate ( ) >= te . getManagementVertex ( ) . getNumberOfInputGates ( ) ) { break ; } if ( te . getCurrentChannel ( ) >= te . getManagementVertex ( ) . getInputGate ( te . getCurrentGate ( ) ) . getNumberOfBackwardEdges ( ) ) { te . increaseCurrentGate ( ) ; te . resetCurrentChannel ( ) ; } else { final ManagementEdge backwardEdge = te . getManagementVertex ( ) . getInputGate ( te . getCurrentGate ( ) ) . getBackwardEdge ( te . getCurrentChannel ( ) ) ; final ManagementVertex source = backwardEdge . getSource ( ) . getVertex ( ) ; if ( source == null ) { LOG . error ( "Inconsistency in vertex map found (backward)!" ) ; } te . increaseCurrentChannel ( ) ; if ( ! this . alreadyVisited . contains ( source ) ) { return source ; } } } } return null ; }
Returns a candidate vertex which could potentially be visited next because it is reachable from the
currently considered vertex.

@param te
the traversal entry for the current source vertex
@param forward
<code>true</code> if the graph should be traversed in correct order, <code>false</code> to traverse it in
reverse order
@return a candidate vertex which could potentially be visited next