Ejemplo n.º 1
0
  /*
   * "...At each time-step, we choose NeY vertices at random, with
   * probabilities proportional to Zi.  For each vertex chosen we
   * choose one of its neighbors uniformly at random and delete the
   * connection to that neighbor...."
   */
  private void removeRandomFriendship() {

    removalMap.clear();
    double zeeSum = 0;
    int nEdges = 0;

    for (int i = 0; i < numNodes; i++) {
      JinGirNewNode node = (JinGirNewNode) agentList.get(i);
      int degree = node.getOutDegree();
      if (degree > 1) {
        removalMap.put(zeeSum, node);
        zeeSum += degree * (degree - 1);
      }

      nEdges += degree;
    }

    nEdges = nEdges / 2;
    int numPicks = (int) Math.round(nEdges * removeProb);

    for (int n = 0; n < numPicks; n++) {
      double pick = Random.uniform.nextDoubleFromTo(0, zeeSum);
      JinGirNewNode node = (JinGirNewNode) removalMap.get(pick);
      node.removeFriend();
    }
  }
Ejemplo n.º 2
0
  /**
   * "...At each time-step, we choose NmR1 vertices at random, with probabilites proportional to
   * Zi(Zi-1). For each vertex chosen we randomly choose on pair of its neighbots to meet, and
   * establish a new connection between them if they do not have a preexisting connection and if
   * neither of them already has the maximum number z* of connections...."
   */
  private void neighborMeeting() {
    neighborMap.clear();
    double zeeSum = 0;
    for (int n = 0; n < numNodes; n++) {
      JinGirNewNode node = (JinGirNewNode) agentList.get(n);
      int degree = node.getOutDegree();
      if (degree > 1) {
        neighborMap.put(zeeSum, node);
        zeeSum += degree * (degree - 1);
      }
    }

    int nM = (int) (zeeSum / 2); // will be even cause #edges even
    int numPicks = (int) Math.round(nM * Rsub1);

    for (int n = 0; n < numPicks; n++) {
      double pick = Random.uniform.nextDoubleFromTo(0, zeeSum);
      JinGirNewNode node = (JinGirNewNode) neighborMap.get(pick);

      /*
           if (node == null) {
      System.out.println("pick: " + pick);
      System.out.println("zeeSum: " + zeeSum);
      neighborMap.print();
           }
           */

      if (node.getOutDegree() > 1) node.meetNeighbor(maxDegree);
    }
  }