Example #1
0
    public void insert(int value)
    {
        if (value > 0)
        {
            { /*$goal 0 reachable*/ }

            BinomialHeapNode temp = new BinomialHeapNode();
            temp.key = value;

            if (Nodes == null)
            {
                { /*$goal 1 reachable*/ }

                Nodes = temp;
                size  = 1;
            }
            else
            {
                { /*$goal 2 reachable*/ }

                unionNodes_insert(temp);
                size++;
            }
        }
        else
        {
            { /*$goal 21 reachable*/ }
        }
    }
Example #2
0
 //$goals 10
 //$benchmark
 public void extractMinTest(BinomialHeap binomialHeap)
 {
     if (binomialHeap != null && binomialHeap.repOK())
     {
         BinomialHeapNode ret_val = binomialHeap.extractMin();
     }
 }
Example #3
0
 //$goals 3
 //$benchmark
 public void decreaseKeyNodeTest(BinomialHeap binomialHeap, BinomialHeapNode node, int new_value)
 {
     if (binomialHeap != null && binomialHeap.repOK())
     {
         binomialHeap.decreaseKeyNode(node, new_value);
     }
 }
Example #4
0
    private static boolean repOK_ordered(final BinomialHeapNode node)
    {
        if (node.child != null)
        {
            if (node.child.key < node.key)
            {
                return(false);
            }
            if (!repOK_ordered(node.child))
            {
                return(false);
            }
            for (BinomialHeapNode ns = node.child.sibling; ns != null; ns = ns.sibling)
            {
                if (ns.key < node.key)
                {
                    return(false);
                }
                if (!repOK_ordered(ns))
                {
                    return(false);
                }
            }
            return(true);
        }

        return(true);
    }
Example #5
0
    // another helper procedure
    private void unionNodes_insert(BinomialHeapNode binHeap)
    {
        merge_insert(binHeap);

        BinomialHeapNode prevTemp = null, temp = Nodes, nextTemp = Nodes.sibling;

        while (nextTemp != null)
        {
            if ((temp.degree != nextTemp.degree) ||
                ((nextTemp.sibling != null) && (nextTemp.sibling.degree == temp.degree)))
            {
                { /*$goal 14 reachable*/ }

                prevTemp = temp;
                temp     = nextTemp;
            }
            else
            {
                { /*$goal 15 reachable*/ }

                if (temp.key <= nextTemp.key)
                {
                    { /*$goal 16 reachable*/ }

                    temp.sibling     = nextTemp.sibling;
                    nextTemp.parent  = temp;
                    nextTemp.sibling = temp.child;
                    temp.child       = nextTemp;
                    temp.degree++;
                }
                else
                {
                    { /*$goal 17 reachable*/ }

                    if (prevTemp == null)
                    {
                        { /*$goal 18 reachable*/ }

                        Nodes = nextTemp;
                    }
                    else
                    {
                        { /*$goal 19 reachable*/ }
                        prevTemp.sibling = nextTemp;
                    }
                    temp.parent    = nextTemp;
                    temp.sibling   = nextTemp.child;
                    nextTemp.child = temp;
                    nextTemp.degree++;
                    temp = nextTemp;
                }
            }

            { /*$goal 20 reachable*/ }
            nextTemp = temp.sibling;
        }
    }
Example #6
0
    // helper procedure
    private void merge_extractMin(BinomialHeapNode binHeap)
    {
        BinomialHeapNode temp1 = Nodes, temp2 = binHeap;

        while ((temp1 != null) && (temp2 != null))
        {
            if (temp1.degree == temp2.degree)
            {
                BinomialHeapNode tmp = temp2;
                temp2         = temp2.sibling;
                tmp.sibling   = temp1.sibling;
                temp1.sibling = tmp;
                temp1         = tmp.sibling;
            }
            else
            {
                if (temp1.degree < temp2.degree)
                {
                    if ((temp1.sibling == null) ||
                        (temp1.sibling.degree > temp2.degree))
                    {
                        BinomialHeapNode tmp = temp2;
                        temp2         = temp2.sibling;
                        tmp.sibling   = temp1.sibling;
                        temp1.sibling = tmp;
                        temp1         = tmp.sibling;
                    }
                    else
                    {
                        temp1 = temp1.sibling;
                    }
                }
                else
                {
                    BinomialHeapNode tmp = temp1;
                    temp1         = temp2;
                    temp2         = temp2.sibling;
                    temp1.sibling = tmp;
                    if (tmp == Nodes)
                    {
                        Nodes = temp1;
                    }
                }
            }
        }

        if (temp1 == null)
        {
            temp1 = Nodes;
            while (temp1.sibling != null)
            {
                temp1 = temp1.sibling;
            }
            temp1.sibling = temp2;
        }
    }
Example #7
0
        /// <summary>
        /// Update the Heap with new value for this node pointer
        /// O(log(n)) complexity
        /// </summary>
        /// <param name="key"></param>
        public void IncrementKey(BinomialHeapNode <T> node)
        {
            var current = node;

            while (current.Parent != null &&
                   current.Value.CompareTo(current.Parent.Value) > 0)
            {
                var tmp = current.Value;
                current.Value        = current.Parent.Value;
                current.Parent.Value = tmp;

                current = current.Parent;
            }
        }
Example #8
0
    public BinomialHeapNode reverse(BinomialHeapNode sibl)
    {
        BinomialHeapNode ret;

        if (sibling != null)
        {
            ret = sibling.reverse(this);
        }
        else
        {
            ret = this;
        }
        sibling = sibl;
        return(ret);
    }
Example #9
0
    private static int repOK_count_nodes(BinomialHeapNode start)
    {
        int node_count = 1;

        BinomialHeapNode child = start.child;

        while (child != null)
        {
            node_count += repOK_count_nodes(child);

            child = child.sibling;
        }

        return(node_count);
    }
Example #10
0
        /// <summary>
        /// O(log(n)) complexity
        /// </summary>
        /// <param name="newItem"></param>
        public BinomialHeapNode <T> Insert(T newItem)
        {
            var newNode = new BinomialHeapNode <T>(newItem);

            var newHeapForest = new DoublyLinkedList <BinomialHeapNode <T> >();

            newHeapForest.InsertFirst(newNode);

            //updated pointer
            MergeSortedForests(newHeapForest);

            Meld();

            Count++;

            return(newNode);
        }
Example #11
0
    public BinomialHeapNode findMinNode()
    {
        BinomialHeapNode x = this, y = this;
        int min = x.key;

        while (x != null)
        {
            if (x.key < min)
            {
                y   = x;
                min = x.key;
            }
            x = x.sibling;
        }

        return(y);
    }
Example #12
0
    // another helper procedure
    private void unionNodes_extractMin(BinomialHeapNode binHeap)
    {
        merge_extractMin(binHeap);

        BinomialHeapNode prevTemp = null, temp = Nodes, nextTemp = Nodes.sibling;

        while (nextTemp != null)
        {
            if ((temp.degree != nextTemp.degree) ||
                ((nextTemp.sibling != null) && (nextTemp.sibling.degree == temp.degree)))
            {
                prevTemp = temp;
                temp     = nextTemp;
            }
            else
            {
                if (temp.key <= nextTemp.key)
                {
                    temp.sibling     = nextTemp.sibling;
                    nextTemp.parent  = temp;
                    nextTemp.sibling = temp.child;
                    temp.child       = nextTemp;
                    temp.degree++;
                }
                else
                {
                    if (prevTemp == null)
                    {
                        Nodes = nextTemp;
                    }
                    else
                    {
                        prevTemp.sibling = nextTemp;
                    }
                    temp.parent    = nextTemp;
                    temp.sibling   = nextTemp.child;
                    nextTemp.child = temp;
                    nextTemp.degree++;
                    temp = nextTemp;
                }
            }

            nextTemp = temp.sibling;
        }
    }
Example #13
0
    private static BinomialHeapNode findMinNode(BinomialHeapNode arg)
    {
        BinomialHeapNode x = arg, y = arg;
        int min = x.key;

        while (x != null)
        {
            { /*$goal 0 reachable*/ }

            if (x.key < min)
            {
                { /*$goal 1 reachable*/ }
                y   = x;
                min = x.key;
            }
            x = x.sibling;
        }

        { /*$goal 2 reachable*/ }
        return(y);
    }
Example #14
0
    public void decreaseKeyNode(BinomialHeapNode node, int new_value)
    {
        if (node == null) {
            {/*$goal 0 reachable*/}
            return;
        }

        node.key = new_value;
        BinomialHeapNode tempParent = node.parent;

        while ((tempParent != null) && (node.key < tempParent.key)) {
            {/*$goal 1 reachable*/}

            int z = node.key;
            node.key = tempParent.key;
            tempParent.key = z;

            node = tempParent;
            tempParent = tempParent.parent;
        }
        {/*$goal 2 reachable*/}
    }
Example #15
0
    public void decreaseKeyNode(BinomialHeapNode node, int new_value)
    {
        if (node == null)
        {
            { /*$goal 0 reachable*/ }
            return;
        }

        node.key = new_value;
        BinomialHeapNode tempParent = node.parent;

        while ((tempParent != null) && (node.key < tempParent.key))
        {
            { /*$goal 1 reachable*/ }

            int z = node.key;
            node.key       = tempParent.key;
            tempParent.key = z;

            node       = tempParent;
            tempParent = tempParent.parent;
        }
        { /*$goal 2 reachable*/ }
    }
Example #16
0
    // helper procedure
    private void merge_insert(BinomialHeapNode binHeap)
    {
        BinomialHeapNode temp1 = Nodes, temp2 = binHeap;

        while ((temp1 != null) && (temp2 != null))
        {
            { /*$goal 3 reachable*/ }

            if (temp1.degree == temp2.degree)
            {
                { /*$goal 4 reachable*/ }

                BinomialHeapNode tmp = temp2;
                temp2         = temp2.sibling;
                tmp.sibling   = temp1.sibling;
                temp1.sibling = tmp;
                temp1         = tmp.sibling;
            }
            else
            {
                { /*$goal 5 reachable*/ }

                if (temp1.degree < temp2.degree)
                {
                    { /*$goal 6 reachable*/ }

                    if ((temp1.sibling == null) ||
                        (temp1.sibling.degree > temp2.degree))
                    {
                        { /*$goal 7 reachable*/ }

                        BinomialHeapNode tmp = temp2;
                        temp2         = temp2.sibling;
                        tmp.sibling   = temp1.sibling;
                        temp1.sibling = tmp;
                        temp1         = tmp.sibling;
                    }
                    else
                    {
                        { /*$goal 8 reachable*/ }

                        temp1 = temp1.sibling;
                    }
                }
                else
                {
                    { /*$goal 9 reachable*/ }

                    BinomialHeapNode tmp = temp1;
                    temp1         = temp2;
                    temp2         = temp2.sibling;
                    temp1.sibling = tmp;
                    if (tmp == Nodes)
                    {
                        { /*$goal 10 reachable*/ }
                        Nodes = temp1;
                    }
                }
            }
        }

        if (temp1 == null)
        {
            { /*$goal 11 reachable*/ }
            temp1 = Nodes;
            while (temp1.sibling != null)
            {
                { /*$goal 12 reachable*/ }
                temp1 = temp1.sibling;
            }

            { /*$goal 13 reachable*/ }
            temp1.sibling = temp2;
        }
    }
Example #17
0
    private static int repOK_count_nodes(BinomialHeapNode start)
    {
        int node_count = 1;

        BinomialHeapNode child = start.child;
        while (child!=null) {

            node_count += repOK_count_nodes(child);

            child=child.sibling;
        }

        return node_count;
    }
Example #18
0
    private static boolean repOK_isAcyclic(BinomialHeapNode start, RoopsList seen)
    {
        if (seen.contains(start))
             return false;

         if (start.degree<0)
             return false;

         seen.add(start);

         BinomialHeapNode child = start.child;

         int child_count = 0;

         while (child!=null) {

             child_count++;

             if (child.parent != start)
                 return false;

             if (!repOK_isAcyclic(child, seen))
                 return false;

             if (child.sibling!=null) {
                 if (child.degree<=child.sibling.degree)
                     return false;
             }
             child = child.sibling;
         }

         if (start.degree!=child_count)
             return false;

         if (start.child!=null) {
             int tam_child=1;
             if (start.child.child!=null) {
                 BinomialHeapNode curr = start.child.child;
                 while (curr!=null) {
                   tam_child+= repOK_count_nodes(start.child.child);
                   curr = curr.sibling;
                 }
             }

             int tam_sibling=1;
             if (start.child.sibling!=null) {
                 BinomialHeapNode curr = start.child.sibling;
                 while (curr!=null) {
                   tam_sibling+= repOK_count_nodes(start.child.sibling);
          			       curr = curr.sibling;
                 }
             }

             if (tam_child!=tam_sibling)
                 return false;

         }

         return true;
    }
Example #19
0
    // another helper procedure
    private void unionNodes_extractMin(BinomialHeapNode binHeap)
    {
        merge_extractMin(binHeap);

        BinomialHeapNode prevTemp = null, temp = Nodes , nextTemp = Nodes.sibling;

        while (nextTemp != null) {
            if ((temp.degree != nextTemp.degree)
                    || ((nextTemp.sibling != null) && (nextTemp.sibling.degree == temp.degree))) {
                prevTemp = temp;
                temp = nextTemp;
            } else {
                if (temp.key <= nextTemp.key) {
                    temp.sibling = nextTemp.sibling;
                    nextTemp.parent = temp;
                    nextTemp.sibling = temp.child;
                    temp.child = nextTemp;
                    temp.degree++;
                } else {
                    if (prevTemp == null) {
                        Nodes = nextTemp;
                    } else {
                        prevTemp.sibling = nextTemp;
                    }
                    temp.parent = nextTemp;
                    temp.sibling = nextTemp.child;
                    nextTemp.child = temp;
                    nextTemp.degree++;
                    temp = nextTemp;
                }
            }

            nextTemp = temp.sibling;
        }
    }
Example #20
0
 //$goals 3
 //$benchmark
 public void decreaseKeyNodeTest(BinomialHeap binomialHeap, BinomialHeapNode node, int new_value)
 {
     if (binomialHeap!=null && binomialHeap.repOK()) {
       binomialHeap.decreaseKeyNode(node, new_value);
     }
 }
Example #21
0
    private static boolean repOK_nodeRepOk(BinomialHeapNode Node)
    {
        RoopsList seen = new RoopsList();

        if (Node != null)
        {
            if (!repOK_isAcyclic(Node, seen))
            {
                return(false);
            }

            if (!repOK_ordered(Node))
            {
                return(false);
            }

            if (Node.parent != null)
            {
                return(false);
            }

            if (Node.sibling != null)
            {
                if (Node.degree >= Node.sibling.degree)
                {
                    return(false);
                }
            }

            BinomialHeapNode ns = Node.sibling;;
            while (ns != null)
            {
                if (!repOK_isAcyclic(ns, seen))
                {
                    return(false);
                }

                if (ns.parent != null)
                {
                    return(false);
                }

                if (ns.sibling != null)
                {
                    if (ns.degree >= ns.sibling.degree)
                    {
                        return(false);
                    }
                }

                if (!repOK_ordered(ns))
                {
                    return(false);
                }

                ns = ns.sibling;
            }
        }

        return(true);
    }
Example #22
0
    private static boolean repOK_nodeRepOk(BinomialHeapNode Node)
    {
        RoopsList seen = new RoopsList();

        if (Node!=null) {

            if (!repOK_isAcyclic(Node, seen))
                return false;

            if (!repOK_ordered(Node))
                return false;

            if (Node.parent!=null)
                return false;

            if (Node.sibling!=null) {
                if (Node.degree >= Node.sibling.degree)
                    return false;
            }

            BinomialHeapNode ns = Node.sibling; ;
            while (ns != null) {

                  if (!repOK_isAcyclic(ns, seen))
                     return false;

                  if (ns.parent!=null)
                      return false;

                  if (ns.sibling!=null) {
                      if (ns.degree>=ns.sibling.degree)
                          return false;
                  }

                  if (!repOK_ordered(ns))
                      return false;

                  ns = ns.sibling;
              }

        }

        return true;
    }
Example #23
0
 private void setParent(BinomialHeapNode par)
 {
     parent = par;
 }
Example #24
0
    // helper procedure
    private void merge_extractMin(BinomialHeapNode binHeap)
    {
        BinomialHeapNode temp1 = Nodes, temp2 = binHeap;
        while ((temp1 != null) && (temp2 != null)) {
            if (temp1.degree == temp2.degree) {
                BinomialHeapNode tmp = temp2;
                temp2 = temp2.sibling;
                tmp.sibling = temp1.sibling;
                temp1.sibling = tmp;
                temp1 = tmp.sibling;
            } else {
                if (temp1.degree < temp2.degree) {
                    if ((temp1.sibling == null)
                            || (temp1.sibling.degree > temp2.degree)) {
                        BinomialHeapNode tmp = temp2;
                        temp2 = temp2.sibling;
                        tmp.sibling = temp1.sibling;
                        temp1.sibling = tmp;
                        temp1 = tmp.sibling;
                    } else {
                        temp1 = temp1.sibling;
                    }
                } else {
                    BinomialHeapNode tmp = temp1;
                    temp1 = temp2;
                    temp2 = temp2.sibling;
                    temp1.sibling = tmp;
                    if (tmp == Nodes) {
                        Nodes = temp1;
                    }
                }
            }
        }

        if (temp1 == null) {
            temp1 = Nodes;
            while (temp1.sibling != null) {
                temp1 = temp1.sibling;
            }
            temp1.sibling = temp2;
        }
    }
Example #25
0
 private void setParent(BinomialHeapNode par)
 {
     parent = par;
 }
Example #26
0
    // another helper procedure
    private void unionNodes_insert(BinomialHeapNode binHeap)
    {
        merge_insert(binHeap);

        BinomialHeapNode prevTemp = null, temp = Nodes , nextTemp = Nodes.sibling;

        while (nextTemp != null) {
            if ((temp.degree != nextTemp.degree)
                    || ((nextTemp.sibling != null) && (nextTemp.sibling.degree == temp.degree))) {

                {/*$goal 14 reachable*/}

                prevTemp = temp;
                temp = nextTemp;
            } else {

                {/*$goal 15 reachable*/}

                if (temp.key <= nextTemp.key) {

                    {/*$goal 16 reachable*/}

                    temp.sibling = nextTemp.sibling;
                    nextTemp.parent = temp;
                    nextTemp.sibling = temp.child;
                    temp.child = nextTemp;
                    temp.degree++;
                } else {

                    {/*$goal 17 reachable*/}

                    if (prevTemp == null) {

                        {/*$goal 18 reachable*/}

                        Nodes = nextTemp;
                    } else {

                        {/*$goal 19 reachable*/}
                        prevTemp.sibling = nextTemp;
                    }
                    temp.parent = nextTemp;
                    temp.sibling = nextTemp.child;
                    nextTemp.child = temp;
                    nextTemp.degree++;
                    temp = nextTemp;
                }
            }

            {/*$goal 20 reachable*/}
            nextTemp = temp.sibling;
        }
    }
Example #27
0
    public BinomialHeapNode extractMin()
    {
        if (Nodes == null)
            return null;

        int old_size = size;

        BinomialHeapNode temp = Nodes, prevTemp = null;
        BinomialHeapNode minNode = findMinNode_extractMin(Nodes);
        while (temp.key != minNode.key) {
            {/*$goal 0 reachable*/}
            prevTemp = temp;
            temp = temp.sibling;
        }

        if (prevTemp == null) {
            {/*$goal 1 reachable*/}
            Nodes = temp.sibling;
        } else {
            {/*$goal 2 reachable*/}
            prevTemp.sibling = temp.sibling;
        }
        temp = temp.child;
        BinomialHeapNode fakeNode = temp;
        while (temp != null) {
            {/*$goal 3 reachable*/}
            temp.parent = null;
            temp = temp.sibling;
        }

        if ((Nodes == null) && (fakeNode == null)) {
            {/*$goal 4 reachable*/}
            size = 0;
        } else {
            if ((Nodes == null) && (fakeNode != null)) {
                {/*$goal 5 reachable*/}
                Nodes = fakeNode.reverse(null);
                size--;
            } else {
                {/*$goal 6 reachable*/}
                if ((Nodes != null) && (fakeNode == null)) {
                    {/*$goal 7 reachable*/}
                    size--;
                } else {
                    {/*$goal 8 reachable*/}
                    unionNodes_extractMin(fakeNode.reverse(null));
                    size--;
                }
            }
        }

        if (this.size==12) {
            {/*$goal 9 reachable*/}
        }
        return minNode;
    }
Example #28
0
    private static BinomialHeapNode findMinNode_extractMin(BinomialHeapNode arg)
    {
        BinomialHeapNode x = arg, y = arg;
        int min = x.key;

        while (x != null) {
            {/*$goal 0 reachable*/}

            if (x.key < min) {
                {/*$goal 1 reachable*/}
                y = x;
                min = x.key;
            }
            x = x.sibling;
        }

        {/*$goal 2 reachable*/}
        return y;
    }
Example #29
0
    //*************************************************************************
    //************************* From now on repOK  ****************************
    //*************************************************************************.

    public boolean repOK()
    {
        RoopsList seen = new RoopsList();

        if (this.Nodes != null)
        {
            if (!repOK_isAcyclic(this.Nodes, seen))
            {
                return(false);
            }

            if (!repOK_ordered(this.Nodes))
            {
                return(false);
            }

            if (this.Nodes.parent != null)
            {
                return(false);
            }

            if (this.Nodes.sibling != null)
            {
                if (this.Nodes.degree >= this.Nodes.sibling.degree)
                {
                    return(false);
                }
            }

            BinomialHeapNode ns = this.Nodes.sibling;
            while (ns != null)
            {
                if (!repOK_isAcyclic(ns, seen))
                {
                    return(false);
                }

                if (ns.parent != null)
                {
                    return(false);
                }

                if (ns.sibling != null)
                {
                    if (ns.degree >= ns.sibling.degree)
                    {
                        return(false);
                    }
                }


                if (!repOK_ordered(ns))
                {
                    return(false);
                }


                ns = ns.sibling;
            }
        }

        int node_count = seen.getSize();

        if (this.size != node_count)
        {
            return(false);
        }

        return(true);
    }
Example #30
0
    public void insert(int value)
    {
        if (value > 0) {
            {/*$goal 0 reachable*/}

            BinomialHeapNode temp = new BinomialHeapNode();
            temp.key = value;

            if (Nodes == null) {
                {/*$goal 1 reachable*/}

                Nodes = temp;
                size = 1;
            } else {
                {/*$goal 2 reachable*/}

                unionNodes_insert(temp);
                size++;
            }
        } else {
            {/*$goal 21 reachable*/}
        }
    }
Example #31
0
    private static boolean repOK_isAcyclic(BinomialHeapNode start, RoopsList seen)
    {
        if (seen.contains(start))
        {
            return(false);
        }

        if (start.degree < 0)
        {
            return(false);
        }

        seen.add(start);

        BinomialHeapNode child = start.child;

        int child_count = 0;

        while (child != null)
        {
            child_count++;

            if (child.parent != start)
            {
                return(false);
            }

            if (!repOK_isAcyclic(child, seen))
            {
                return(false);
            }

            if (child.sibling != null)
            {
                if (child.degree <= child.sibling.degree)
                {
                    return(false);
                }
            }
            child = child.sibling;
        }

        if (start.degree != child_count)
        {
            return(false);
        }

        if (start.child != null)
        {
            int tam_child = 1;
            if (start.child.child != null)
            {
                BinomialHeapNode curr = start.child.child;
                while (curr != null)
                {
                    tam_child += repOK_count_nodes(start.child.child);
                    curr       = curr.sibling;
                }
            }

            int tam_sibling = 1;
            if (start.child.sibling != null)
            {
                BinomialHeapNode curr = start.child.sibling;
                while (curr != null)
                {
                    tam_sibling += repOK_count_nodes(start.child.sibling);
                    curr         = curr.sibling;
                }
            }

            if (tam_child != tam_sibling)
            {
                return(false);
            }
        }

        return(true);
    }
Example #32
0
 private void setSibling(BinomialHeapNode nextBr)
 {
     sibling = nextBr;
 }
Example #33
0
 public BinomialHeapNode reverse(BinomialHeapNode sibl)
 {
     BinomialHeapNode ret;
     if (sibling != null)
         ret = sibling.reverse(this);
     else
         ret = this;
     sibling = sibl;
     return ret;
 }
Example #34
0
    public BinomialHeapNode extractMin()
    {
        if (Nodes == null)
        {
            return(null);
        }

        int old_size = size;

        BinomialHeapNode temp = Nodes, prevTemp = null;
        BinomialHeapNode minNode = findMinNode_extractMin(Nodes);

        while (temp.key != minNode.key)
        {
            { /*$goal 0 reachable*/ }
            prevTemp = temp;
            temp     = temp.sibling;
        }

        if (prevTemp == null)
        {
            { /*$goal 1 reachable*/ }
            Nodes = temp.sibling;
        }
        else
        {
            { /*$goal 2 reachable*/ }
            prevTemp.sibling = temp.sibling;
        }
        temp = temp.child;
        BinomialHeapNode fakeNode = temp;

        while (temp != null)
        {
            { /*$goal 3 reachable*/ }
            temp.parent = null;
            temp        = temp.sibling;
        }

        if ((Nodes == null) && (fakeNode == null))
        {
            { /*$goal 4 reachable*/ }
            size = 0;
        }
        else
        {
            if ((Nodes == null) && (fakeNode != null))
            {
                { /*$goal 5 reachable*/ }
                Nodes = fakeNode.reverse(null);
                size--;
            }
            else
            {
                { /*$goal 6 reachable*/ }
                if ((Nodes != null) && (fakeNode == null))
                {
                    { /*$goal 7 reachable*/ }
                    size--;
                }
                else
                {
                    { /*$goal 8 reachable*/ }
                    unionNodes_extractMin(fakeNode.reverse(null));
                    size--;
                }
            }
        }

        if (this.size == 12)
        {
            { /*$goal 9 reachable*/ }
        }
        return(minNode);
    }
Example #35
0
 private void setSibling(BinomialHeapNode nextBr)
 {
     sibling = nextBr;
 }
Example #36
0
    // helper procedure
    private void merge_insert(BinomialHeapNode binHeap)
    {
        BinomialHeapNode temp1 = Nodes, temp2 = binHeap;
        while ((temp1 != null) && (temp2 != null)) {

            {/*$goal 3 reachable*/}

            if (temp1.degree == temp2.degree) {

                {/*$goal 4 reachable*/}

                BinomialHeapNode tmp = temp2;
                temp2 = temp2.sibling;
                tmp.sibling = temp1.sibling;
                temp1.sibling = tmp;
                temp1 = tmp.sibling;
            } else {

                {/*$goal 5 reachable*/}

                if (temp1.degree < temp2.degree) {

                    {/*$goal 6 reachable*/}

                    if ((temp1.sibling == null)
                            || (temp1.sibling.degree > temp2.degree)) {

                        {/*$goal 7 reachable*/}

                        BinomialHeapNode tmp = temp2;
                        temp2 = temp2.sibling;
                        tmp.sibling = temp1.sibling;
                        temp1.sibling = tmp;
                        temp1 = tmp.sibling;
                    } else {

                        {/*$goal 8 reachable*/}

                        temp1 = temp1.sibling;
                    }
                } else {
                    {/*$goal 9 reachable*/}

                    BinomialHeapNode tmp = temp1;
                    temp1 = temp2;
                    temp2 = temp2.sibling;
                    temp1.sibling = tmp;
                    if (tmp == Nodes) {
                        {/*$goal 10 reachable*/}
                        Nodes = temp1;
                    }
                }
            }
        }

        if (temp1 == null) {

            {/*$goal 11 reachable*/}
            temp1 = Nodes;
            while (temp1.sibling != null) {

                {/*$goal 12 reachable*/}
                temp1 = temp1.sibling;
            }

            {/*$goal 13 reachable*/}
            temp1.sibling = temp2;
        }
    }
Example #37
0
 private void setChild(BinomialHeapNode firstCh)
 {
     child = firstCh;
 }
Example #38
0
 private void setChild(BinomialHeapNode firstCh)
 {
     child = firstCh;
 }