Exemplo n.º 1
0
 private void addSubtree(Set<String> nodes, ConcRel cr) {
   if (!nodes.contains(cr.getConceptID())) {
     nodes.add(cr.getConceptID());
     for (ConcRel crc : cr.getChildren()) {
       addSubtree(nodes, crc);
     }
   }
 }
Exemplo n.º 2
0
 private void addConcepts(
     ConceptGraph cg, String conceptId, Set<String> nodesToInclude, Set<String> leaves) {
   ConcRel cr = cg.getConceptMap().get(conceptId);
   // only process this node if it isn't already in the list
   if (!nodesToInclude.contains(cr.getConceptID())) {
     // add me to the list
     nodesToInclude.add(cr.getConceptID());
     // iterate over parents and recurse
     for (ConcRel crp : cr.getParents()) {
       addConcepts(cg, crp.getConceptID(), nodesToInclude, leaves);
       // parent is not a leaf - remove it from the list of candidate
       // leaves
       leaves.remove(crp.getConceptID());
     }
   }
 }
Exemplo n.º 3
0
 private Set<String> exportEdges(
     ConceptGraph cg,
     Set<String> nodesToInclude,
     Set<String> leaves,
     int leafChildrenDepth,
     BufferedWriter network)
     throws IOException {
   Set<String> exportedNodes = new HashSet<String>();
   for (String conceptID : nodesToInclude) {
     ConcRel cr = cg.getConceptMap().get(conceptID);
     exportedNodes.add(cr.getConceptID());
     for (ConcRel crc : cr.getChildren()) {
       network.write(crc.getConceptID());
       network.write("\tisa\t");
       network.write(cr.getConceptID());
       network.write("\n");
       exportedNodes.add(crc.getConceptID());
     }
   }
   return exportedNodes;
 }