Пример #1
0
 public static Multimap<Node, Quad> indexQuadsByNode(Collection<Quad> quads) {
   Multimap<Node, Quad> result = HashMultimap.create();
   for (Quad quad : quads) {
     Node[] nodes = QuadUtils.quadToArray(quad);
     for (Node node : nodes) {
       result.put(node, quad);
     }
   }
   return result;
 }
Пример #2
0
  public static boolean isPotentialMatchUnderMapping(
      Quad candQuad, Quad queryQuad, Map<Var, Var> partialSolution) {
    Node[] candNodes = QuadUtils.quadToArray(candQuad);
    Node[] queryNodes = QuadUtils.quadToArray(queryQuad);

    boolean result = true;
    for (int i = 0; i < 4 && result; ++i) {
      Node candNode = candNodes[i];
      Node queryNode = queryNodes[i];

      Node candMap = partialSolution.get(candNode);
      Node queryMap = partialSolution.get(queryNode);

      result =
          result
              && (candMap != null && queryMap != null && candMap.equals(queryMap)
                  || candMap == null && queryMap == null);
    }

    return result;
  }