Ejemplo n.º 1
0
 public Collection<DAGNode> getTagged(String tag) {
   String alterTag = TAG_PREFIX + tag;
   Collection<DAGNode> allTagged = new ArrayList<>();
   if (taggedNodes_.containsKey(alterTag)) allTagged.addAll(taggedNodes_.get(alterTag));
   String nonCoreTag = NON_CORE_PREFIX + tag;
   if (taggedNodes_.containsKey(nonCoreTag)) allTagged.addAll(taggedNodes_.get(nonCoreTag));
   return allTagged;
 }
Ejemplo n.º 2
0
  private boolean getSubNodesAndEdges(
      String tag, int distance, Collection<DAGEdge> edges, Collection<DAGNode> nodes) {
    RelatedEdgeModule relatedEdgeModule =
        (RelatedEdgeModule) dag_.getModule(RelatedEdgeModule.class);

    if (!taggedNodes_.containsKey(tag)) return false;

    // 1. Identify tagged nodes
    Collection<DAGNode> newlyAddedNodes = new HashSet<>(taggedNodes_.get(tag));
    logger.debug("Identify tagged nodes: {}", newlyAddedNodes);

    boolean loop = false;
    do {
      // 2. Find links/ancestry of tagged nodes
      logger.debug("Find links/ancestry of tagged nodes {}", distance);
      findLinks(newlyAddedNodes, nodes, distance, relatedEdgeModule);
      logger.debug("Number of nodes: {}", newlyAddedNodes.size());

      // 3. Find other links between new nodes
      logger.debug("Linking nodes");
      edges.addAll(incorporateNewAndLinkEdges(nodes, newlyAddedNodes, relatedEdgeModule));
      logger.debug("Found {} linking edges.", edges.size());

      loop = !newlyAddedNodes.isEmpty();
      distance = 0;
    } while (loop);
    return true;
  }