static void ai_gc_scan(S root) { ai_gc_clear(); time "GC Scan" { ai_postTriple(root, "has GC distance", "0"); HashMap distances = lithashmap(root, 0); LinkedList queue = litLinkedList(root); S word; while ping ((word = queue.poll()) != null) { int d = distances.get(word)+1; for (WebNode node : indexedNodes(word)) for (WebNode n : web_forwardOrBackwardRelated(node)) { S text = ai_shortenForIndex(web_text(n)); Int od = distances.get(text); if (od == null || d < od) { distances.put(text, d); queue.add(text); } } } } print(l(distances) + "/" + l(indexedTerms()) + " terms were reached in GC scan from " + quote(root) + "."); }