Ejemplo n.º 1
0
  /** Is tag reachable from node on paths with no visited nodes? */
  private Node reachesTag(Node node, UniqueTag tag, Set<Node> visited) {
    assert (node.isRep());
    if (visited.contains(node)) return null;
    if (tag.mergeable(node.tag)) return node;

    visited.add(node);

    if (secondary_index[2]) {
      for (Field f : node.infields.keySet())
        for (FieldEdge e : node.infields.get(f)) {
          assert (e.dst == node);
          Node result = reachesTag(e.src.getRep(), tag, visited);
          if (result != null) return result;
        }
    } else {
      for (Field f : fedges.keySet())
        for (FieldEdge e : fedges.get(f)) {
          if (e.dst != node) continue;
          Node result = reachesTag(e.src, tag, visited);
          if (result != null) return result;
        }
    }
    return null;
  }
Ejemplo n.º 2
0
 /** Does the graph contain a node of a given tag? */
 private Node containsTag(UniqueTag tag) {
   for (Node node : nodes) if (node.isRep() && tag.mergeable(node.tag)) return node;
   return null;
 }