Exemple #1
0
 /**
  * <<<<<<< HEAD topk ��½ҳ ======= topk 着陆页 >>>>>>> seuvislogwws/master
  *
  * @param topK
  * @return
  */
 public List<URLNode> topKLandPage(int topK) {
   List<URLNode> mainland_nodes = new ArrayList<URLNode>();
   List<? extends Node> nodes = this.getNodes();
   for (Node node : nodes) {
     URLNode n = (URLNode) node;
     if (n.getDepth() == 0) {
       //                System.out.println(n.getIn_degree());
       for (URLNode no : mainland_nodes) {
         //                    System.out.print(no.getIn_degree()+"  ");
       }
       if (mainland_nodes.size() < topK) {
         mainland_nodes.add(n);
       } else {
         URLNode minnode = getMinNode(mainland_nodes, "in_degree");
         //                    System.out.print("[" + minnode.getIn_degree() + "]");
         if (minnode.getIn_degree() < n.getIn_degree()) {
           mainland_nodes.remove(minnode);
           mainland_nodes.add(n);
         }
       }
       //                System.out.println();
     }
   }
   return mainland_nodes;
 }
Exemple #2
0
 /**
  * <<<<<<< HEAD �õ�nodes��List��indegree����λ�� ======= 得到nodes的List的indegree的中位数 >>>>>>>
  * seuvislogwws/master
  */
 public double getMiddle(List<? extends Node> nodes) {
   double[] indegree = new double[nodes.size()];
   int i = 0;
   for (Node node : nodes) {
     URLNode n = (URLNode) node;
     indegree[i] = n.getIn_degree();
     i++;
   }
   double middle = quickSelect(indegree, 0, indegree.length - 1, indegree.length / 2);
   return middle;
 }
Exemple #3
0
 /**
  * <<<<<<< HEAD ȡ��nodes��ij��ָ����С��node ======= 取得nodes中某个指标最小的node >>>>>>> seuvislogwws/master
  *
  * @param nodes
  * @param param
  * @return
  */
 public URLNode getMinNode(List<URLNode> nodes, String param) {
   URLNode node = nodes.get(0);
   for (int i = 1; i < nodes.size(); i++) {
     double quota1 = 0;
     double quota2 = 0;
     if (param.equals("in_degree")) {
       quota1 = node.getIn_degree();
       quota2 = nodes.get(i).getIn_degree();
     }
     if (param.equals("drop_percent")) {
       quota1 = node.getDrop_per();
       quota2 = nodes.get(i).getDrop_per();
     }
     if (quota1 > quota2) node = nodes.get(i);
   }
   return node;
 }
Exemple #4
0
  /** <<<<<<< HEAD topK ���ҳ ======= topK 跳出页 >>>>>>> seuvislogwws/master */
  public List<URLNode> topKDropPage(int k) {
    List<URLNode> highdrop_nodes = new ArrayList<URLNode>();
    List<? extends Node> nodes = this.getNodes();
    // ���ҵ����нڵ��indegree����λ��

    double middle = getMiddle(nodes);
    for (Node node : nodes) {
      URLNode n = (URLNode) node;
      if (n.getIn_degree() > middle) {
        if (highdrop_nodes.size() < k) {
          highdrop_nodes.add(n);
        } else {
          URLNode minNode = getMinNode(highdrop_nodes, "drop_percent");
          if (minNode.getDrop_per() < n.getDrop_per()) {
            highdrop_nodes.remove(minNode);
            highdrop_nodes.add(n);
          }
        }
      }
    }
    return highdrop_nodes;
  }