コード例 #1
0
  public void pairWiseCombine() {

    ary = new Object[100000];
    if (min.right == min) { // case with only 1 node
      return;
    } else {

      ary[min.getDegree()] = min;
      Fnode temp = min.right;
      if (temp.degree == 1000) {}

      if (temp.right == min) { // case with only 2 nodes in F heap
        if (min.getDegree() == temp.getDegree()) {
          pwcReadjust2(min, temp);
        } else {
          return;
        }

      } else { // rest of cases
        Fnode store = min.left;
        while (temp != store) {
          Fnode holder = temp.right;
          pwcReadjust(temp);
          temp = holder;
        }
        pwcReadjust(store);
      }
      // traverse();
    }
  }
コード例 #2
0
  public void pwcReadjust(Fnode temp) { // takes the node and compares if
    // another with same degree exists
    if (ary[temp.getDegree()] == null) { // and if it exists it checks the
      // smaller and calls
      // pwcReadjust(smaller,larger)
      ary[temp.getDegree()] = temp;

    } else {
      Fnode temp2 = (Fnode) ary[temp.getDegree()];
      if ((int) temp2.data < (int) temp.data) {
        pwcReadjust2(temp2, temp);

      } else {
        pwcReadjust2(temp, temp2);
      }
    }
  }