コード例 #1
0
 private static Wrapper getFirstNode(WrappedGraphData wgd) {
   for (Wrapper node : wgd.getPositionedNodes()) {
     if (node.getPreviousNodesCount() == 0) {
       return node;
     }
   }
   return null;
 }
コード例 #2
0
 public static void test(final AbstractGraphData origin) {
   origin
       .getGenomes()
       .stream()
       .map(Genome::getIdentifier)
       .forEach(
           string -> {
             List<DataNode> nodeList = origin.getNodeListClone();
             List<String> list = new ArrayList<>();
             list.add(string);
             new GenomeFilter(list).filter(nodeList);
             List<Edge> edgeList = origin.getEdgeListClone();
             EdgeUtil.removeAllDeadEdges(edgeList, nodeList);
             GraphData gd = new GraphData(origin, nodeList, edgeList, origin.getGenomes());
             WrappedGraphData wgd = new WrappedGraphData(gd);
             Wrapper node = getFirstNode(wgd);
             Set<Wrapper> set = new HashSet<>(wgd.getPositionedNodes());
             set.remove(node);
             while (true) {
               if (node.getOutgoing().size() == 1) {
                 node = node.getOutgoing().get(0);
               } else if (node.getOutgoing().size() > 1) {
                 int min = Integer.MAX_VALUE;
                 Wrapper newNode = null;
                 for (Wrapper out : node.getOutgoing()) {
                   if (out.getPreviousNodesCount() < min) {
                     min = out.getPreviousNodesCount();
                     newNode = out;
                   }
                 }
                 node = newNode;
               } else {
                 break;
               }
               set.remove(node);
             }
             if (set.size() != 0) {
               try {
                 throw new DuplicateGenomeNameException(
                     "Genome is not fully connected.",
                     "Parse test. Found " + set.size() + " remaining nodes.");
               } catch (Exception e) {
                 e.printStackTrace();
               }
               Assert.fail();
             }
           });
 }