* extensionStack} will be empty upon this method's return.
*/
private void loadNextExtension() {
// Get the set of vertices that are on the top of the stack
// currently
TIntHashSet extension = extensionStack.peek();
if (extension == null)
throw new IllegalStateException();
if (extension.isEmpty())
return;
// Choose and remove an aribitrary vertex from the extension
TIntIterator iter = extension.iterator();
Integer w = iter.next();
iter.remove();
// The next extension is formed from all edges to vertices whose
// indices are greater than the currently selected vertex, w,
// and that point to a vertex in the exclusive neighborhood of
// w. The exclusive neighborhood is defined relative to a set
// of vertices N: all vertices that are adjacent to w but are
// not in N or the neighbors of N. In this case, N is the
// current subgraph's vertices
TIntHashSet nextExtension = new TIntHashSet(extension);
next_vertex:
for (Integer n : g.getNeighbors(w)) {
// Perform the fast vertex value test and check for whether
// the vertex is currently in the subgraph
if (n > v && !vertsInSubgraph.contains(n)) {
// Then perform the most expensive
// exclusive-neighborhood test that looks at the
// neighbors of the vertices in the current subgraph
Iterator<Integer> subIter = vertsInSubgraph.iterator();
while (subIter.hasNext()) {
int inCur = subIter.next();
// If we find n within the neighbors of a vertex in
// the current subgraph, then skip the remaining
// checks and examine another vertex adjacent to w.
if (g.contains(inCur, n))
continue next_vertex;
}
// Otherwise, n is in the exclusive neighborhood of w,
// so add it to the future extension.
nextExtension.add(n);
}
}
vertsInSubgraph.push(w);
extensionStack.push(nextExtension);
}