// Process the queue
while (!queue.isEmpty())
{
Node current = queue.remove(0);
// Process edges towards the direction
for (Edge edge : isFwd ? current.getDownstream() : current.getUpstream())
{
// Label the edge considering direction of traversal and type of current node
if (isFwd || !current.isBreadthNode())
{
setLabel(edge, getLabel(current));
}
else
{
setLabel(edge, getLabel(current) + 1);
}
// Get the other end of the edge
Node neigh = isFwd ? edge.getTargetNode() : edge.getSourceNode();
// Process the neighbor if not processed or not in queue
if (getColor(neigh) == WHITE)
{
// Label the neighbor according to the search direction and node type
if (!neigh.isBreadthNode() || !isFwd)
{
setLabel(neigh, getLabel(edge));
}
else
{
setLabel(neigh, getLabel(current) + 1);
}
// Check if we need to stop traversing the neighbor, enqueue otherwise
if ((stopSet == null || !stopSet.contains(neigh)) &&
(!neigh.isBreadthNode() || getLabel(neigh) < limit))
{
setColor(neigh, GRAY);
// Enqueue the node according to its type
if (neigh.isBreadthNode())
{
queue.addLast(neigh);
}
else
{