Package primitives.cluster

Examples of primitives.cluster.ClusterNode


    for(Node n : result.getNodes()){
      g.addNode(n);
    }
   
    while(!toVisit.isEmpty()){
      ClusterNode current = toVisit.pop();
      ret += calculateComplexity(current, g,  result);
     
    }
   
    if(ret == 0){
View Full Code Here


      }
      if(current.item == b){
        depthB = current.depth;
      }
      if(current.item.encapsulates()){
        ClusterNode cast = (ClusterNode)current.item;
        for(IClusterLevel c : cast.getChildren())
            stack.push(new SearchPair(current.depth+1, c));
      }
     
     
    }
View Full Code Here

    toLookAt.push(tree);
    IClusterLevel deepest = tree;
    while(!toLookAt.isEmpty()){
      IClusterLevel current = toLookAt.pop();
      if(!current.encapsulates()) continue;
      ClusterNode cast = (ClusterNode)current;
      if(current.contains(n1) && current.contains(n2)){
        deepest = current;
        for(IClusterLevel c : cast.getChildren())
          toLookAt.push(c);
      }
     
     
    }
View Full Code Here


            if (cur == null) {
                throw new RuntimeException(String.format("ERROR: Missing node %d, known nodes: %s", i, nodenumbers.keySet()));
            }
            ClusterNode parent = parents.get(parentNumber);
            if (parent == null) {
                parent = new ClusterNode();
                parent.setID(parentNumber);
                ch.addChild(parent);
                parents.put(parentNumber, parent);
            }
            parent.addNode(cur);
            nodes.remove(cur);


        }
        if (!nodes.isEmpty()) {
View Full Code Here

        treenodes.put(0,newTree);
               
        //allocate each node to its parent:
        for(int i = 0; i<originalTree.getNodes().size(); i++){
            int parent = assignments.get(i);
            ClusterNode parentNode = treenodes.get(parent);
            if(parentNode == null){
                parentNode = new ClusterNode();
                treenodes.put(parent, parentNode);
            }
            parentNode.addNode(nodenumbers.get(i+1));
           
        }
        //state is now that there are loads of clusters with the children they need.
        //build the tree:
        int treeSize = originalTree.getNodes().size();
        for(int i = 0; i<assignments.size() - treeSize; i++){
            int parent = assignments.get(i + treeSize); //pull parent id for child i from the array.
            if(parent == i+1){
                //Logger.getLogger(TreeTranslator.class.getName()).log(Level.INFO, "Attempted to make a child a parent of itself {0} from {1}",new Object[]{parent,i});
                parent = 0;
            }
            ClusterNode parentNode = treenodes.get(parent); //parent is whatever that value was
            if(parentNode == null){
                //add intermediate parent that didn't have any nodes in it:
                parentNode = new ClusterNode();
                treenodes.put(parent,parentNode);
            }
            ClusterNode childNode = treenodes.get(i + 1); //i starts 0..n-1, they're numbered 1..n (0 is always reserved for the child).
            if(childNode == null){
                childNode = new ClusterNode();
                treenodes.put(i+1, childNode);
            }
            parentNode.addChild(childNode);
            if(ClusterUtils.isCyclic(parentNode)){
                parentNode.deleteChild(childNode);
                //Logger.getLogger(TreeTranslator.class.getName()).log(Level.INFO, "{0} was cyclic so the child {1} was removed", new Object[]{parentNode, childNode});
               
            }
        }
       
        Set<ClusterNode> orphans = new HashSet<ClusterNode>();
       

        for(ClusterNode n : treenodes.values()){
            if(n != newTree && ClusterUtils.findParent(n, newTree) == null){
                orphans.add(n);
            }
        }

       
        for (Iterator<ClusterNode> it = orphans.iterator(); it.hasNext();) {
            ClusterNode clusterNode = it.next();
           
            boolean remove = false;
            for(ClusterNode cn : orphans){
                if(cn != clusterNode && ClusterUtils.findParent(clusterNode, cn) != null){
                    //if the current clusterNode can be found in any of the "trees" of the orphans
View Full Code Here

      break;
    case SPLIT:
      try {
        // ClusterUtils.split(tree,
        // ClusterUtils.lookupIndexInTree(tree,nextInstruction.getOperand1()));
        ClusterNode toSplit = (ClusterNode) ClusterUtils.lookupIndexInTree(nextInstruction.getOperand1(), tree);
        ClusterNode parent = (ClusterNode) ClusterUtils.findParent(
            toSplit, tree);
        ClusterUtils.explode(toSplit, parent, tree);
      } catch (UndefinedIndexException e) {
                                Logger.getLogger(VecInterpreter.class.getName()).log(Level.WARNING, "Operand of SPLIT instruction not found", e);
        // ClusterUtils.split(tree, e.getDefaultNode());
View Full Code Here

  Node outsideIn;
  Node outsideOut;
  Node a,b;
  @Before
  public void setUp() throws Exception {
    c = new ClusterNode();
    a = new Node("a");
    b = new Node("b");
    outsideIn = new Node("outside -> in ");
    outsideOut = new Node("cluster -> outside");
    c.addNode(a);
View Full Code Here

  @Test
  public void testClusterSetOfNode() {
    HashSet<Node> hs = new HashSet<Node>();
    hs.add(a); hs.add(b);
    c = new ClusterNode(hs);
    assertTrue(c.getNodes().contains(a));
    assertTrue(c.contains(a));
    hs.remove(a);
    hs.remove(b);
    assertFalse(c.getNodes().isEmpty());
View Full Code Here

  public void testTree(){
    IClusterLevel leaf1 = new ClusterLeaf();
    leaf1.addNode(b);
    ClusterLeaf leaf2 = new ClusterLeaf();
    leaf2.addNode(a);
    ClusterNode head = new ClusterNode();
    ClusterNode body = new ClusterNode();
    head.addChild(body);
    head.addChild(leaf1);
    body.addChild(leaf2);
    IClusterLevel leaf3 = new ClusterLeaf();
    leaf3.addNode(outsideIn);
    body.addChild(leaf3);
    assertTrue(head.contains(a));
    assertTrue(head.contains(b));
    assertTrue(head.contains(outsideIn));
    head.addNode(outsideOut);
    assertTrue(head.contains(outsideOut));
View Full Code Here

  ClusterNode body;
  ClusterHead head;
  Graph g;
  @Before
  public void setUp() throws Exception {
    c = new ClusterNode();
    a = new Node("a");
    b = new Node("b");
    g = new Graph();
    g.addNode(a);
    g.addNode(b);
    outsideIn = new Node("outside -> in ");
    outsideOut = new Node("cluster -> outside");
    c.addNode(a);
    c.addNode(b);
    outsideIn.connect(a," a ");
    b.connect(outsideOut, " b ");
    g.addNode(outsideIn);
    g.addNode(outsideOut);
   
    leaf1 = new ClusterLeaf();
    leaf2 = new ClusterLeaf();
    leaf3 = new ClusterLeaf();
    head = new ClusterHead(g);
    body = new ClusterNode();
   
    leaf1.addNode(b);

    leaf2.addNode(a);
View Full Code Here

TOP

Related Classes of primitives.cluster.ClusterNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.