it.unimi.dsi.fastutil.ints.IntArrayFIFOQueue Java Examples

The following examples show how to use it.unimi.dsi.fastutil.ints.IntArrayFIFOQueue. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GlobalVisitStats.java    From fasten with Apache License 2.0 6 votes vote down vote up
public static int reachable(final ImmutableGraph graph, final int startingNode) {
	final int n = graph.numNodes();
	final boolean[] known = new boolean[n];
	final IntArrayFIFOQueue queue = new IntArrayFIFOQueue();

	queue.enqueue(startingNode);
	known[startingNode] = true;
	int visited = 0;

	while (!queue.isEmpty()) {
		final int currentNode = queue.dequeueInt();
		visited++;
		final LazyIntIterator iterator = graph.successors(currentNode);
		for (int succ; (succ = iterator.nextInt()) != -1;) {
			if (!known[succ]) {
				known[succ] = true;
				queue.enqueue(succ);
			}
		}
	}

	return visited;
}
 
Example #2
Source File: VisitStats.java    From fasten with Apache License 2.0 6 votes vote down vote up
public static int reachable(final ImmutableGraph graph, final int startingNode) {
	final int n = graph.numNodes();
	final boolean[] known = new boolean[n];
	final IntArrayFIFOQueue queue = new IntArrayFIFOQueue();

	queue.enqueue(startingNode);
	known[startingNode] = true;
	int visited = 0;

	while (!queue.isEmpty()) {
		final int currentNode = queue.dequeueInt();
		visited++;
		final LazyIntIterator iterator = graph.successors(currentNode);
		for (int succ; (succ = iterator.nextInt()) != -1;) {
			if (!known[succ]) {
				known[succ] = true;
				queue.enqueue(succ);
			}
		}
	}

	return visited;
}