diff --git a/code/functions/search-query/java/nu/marginalia/functions/searchquery/query_parser/model/QWordGraph.java b/code/functions/search-query/java/nu/marginalia/functions/searchquery/query_parser/model/QWordGraph.java
index 272b7b35..4da9a6d1 100644
--- a/code/functions/search-query/java/nu/marginalia/functions/searchquery/query_parser/model/QWordGraph.java
+++ b/code/functions/search-query/java/nu/marginalia/functions/searchquery/query_parser/model/QWordGraph.java
@@ -10,7 +10,8 @@ import java.util.stream.Stream;
* with a single start node and a single end node, denoted by QWord.beg() and QWord.end() respectively.
*
* Naively, every path from the start to the end node should represent a valid query variant, although in
- * practice it is desirable to be clever about how to evaluate the paths, to avoid combinatorial explosion.
+ * practice it is desirable to be clever about how to evaluate the paths, to avoid a large number of queries
+ * being generated.
*/
public class QWordGraph implements Iterable {
@@ -85,6 +86,7 @@ public class QWordGraph implements Iterable {
public List links() {
return Collections.unmodifiableList(links);
}
+
public List nodes() {
return links.stream()
.flatMap(l -> Stream.of(l.from(), l.to()))
@@ -120,39 +122,6 @@ public class QWordGraph implements Iterable {
.toList();
}
- // Returns true if removing the word would disconnect the graph
- // so that there is no path from 'begin' to 'end'. This is useful
- // in breaking up the graph into smaller component subgraphs, and
- // understanding which vertexes can be re-ordered without changing
- // the semantics of the encoded query.
- public boolean isBypassed(QWord word, QWord begin, QWord end) {
- Set edge = new HashSet<>();
- Set visited = new HashSet<>();
-
- edge.add(begin);
-
- while (!edge.isEmpty()) {
- Set next = new HashSet<>();
-
- for (var w : edge) {
- // Skip the word we're trying find a bypassing route for
- if (w.ord() == word.ord())
- continue;
-
- if (Objects.equals(w, end))
- return true;
-
- next.addAll(getNext(w));
- }
-
- next.removeAll(visited);
- visited.addAll(next);
- edge = next;
- }
-
- return false;
- }
-
public Map> forwardReachability() {
Map> ret = new HashMap<>();
diff --git a/code/functions/search-query/test/nu/marginalia/functions/searchquery/query_parser/model/QWordGraphTest.java b/code/functions/search-query/test/nu/marginalia/functions/searchquery/query_parser/model/QWordGraphTest.java
index f3201b9d..9c47e980 100644
--- a/code/functions/search-query/test/nu/marginalia/functions/searchquery/query_parser/model/QWordGraphTest.java
+++ b/code/functions/search-query/test/nu/marginalia/functions/searchquery/query_parser/model/QWordGraphTest.java
@@ -9,40 +9,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
class QWordGraphTest {
- @Test
- public void testAddConstructor() {
- QWordGraph graph = new QWordGraph("hello", "world");
-
- System.out.println(graph.isBypassed(graph.nodes().get(1), QWord.beg(), QWord.end()));
- System.out.println(graph.isBypassed(graph.nodes().get(2), QWord.beg(), QWord.end()));
- System.out.println(graph.compileToQuery());
- graph.forwardReachability().entrySet().stream().sorted(Comparator.comparing(e -> e.getKey().ord())).forEach(System.out::println);
- graph.links().forEach(System.out::println);
- System.out.println("--");
- graph.nodes().forEach(System.out::println);
- System.out.println("--");
- graph.addVariant(graph.nodes().get(1), "sup");
- System.out.println(graph.compileToQuery());
- graph.forwardReachability().entrySet().stream().sorted(Comparator.comparing(e -> e.getKey().ord())).forEach(System.out::println);
- System.out.println(graph.isBypassed(graph.nodes().get(1), QWord.beg(), QWord.end()));
- System.out.println(graph.isBypassed(graph.nodes().get(2), QWord.beg(), QWord.end()));
- System.out.println("--");
- graph.links().forEach(System.out::println);
- System.out.println("--");
- graph.nodes().forEach(System.out::println);
-
- graph.addVariantForSpan(graph.nodes().get(1), graph.nodes().get(2), "heyall");
- graph.addVariant(graph.nodes().get(2), "globe");
- System.out.println(graph.compileToQuery());
- System.out.println(graph.isBypassed(graph.nodes().get(1), QWord.beg(), QWord.end()));
- System.out.println(graph.isBypassed(graph.nodes().get(2), QWord.beg(), QWord.end()));
- System.out.println("--");
- graph.links().forEach(System.out::println);
- System.out.println("--");
- graph.nodes().forEach(System.out::println);
- graph.forwardReachability().entrySet().stream().sorted(Comparator.comparing(e -> e.getKey().ord())).forEach(System.out::println);
- }
-
@Test
void forwardReachability() {
// Construct a graph like