public double getNeighborhoodConductance()

in src/main/java/com/twitter/sbf/graph/Graph.java [92:123]


  public double getNeighborhoodConductance(int i) {
    if (this.getDegree(i) < 2) {
      return 1.0;
    }
    double cut = 0;
    double vol = 0;

    for (Integer vertexId : this.getNeighbors(i)) {
      Iterator<WeightedId> wni = this.getWeightedNeighborsIterator(vertexId);
      while (wni.hasNext()) {
        WeightedId wn = wni.next();
        if (!this.isNeighbors(wn.neighborId, i) && wn.neighborId != i) {
          cut += wn.weight;
        }
      }
      vol += this.getWeightedOutDegree(vertexId);
    }
    vol += this.getWeightedOutDegree(i);

    double totalEdgeWt = 0;
    if (this.isWeighted()) {
      totalEdgeWt = 2.0 * this.getNumEdges() * this.getGlobalAvgWeight();
    } else {
      totalEdgeWt = 2.0 * this.getNumEdges();
    }

    if (vol != totalEdgeWt && vol != 0) {
      return cut / Math.min(vol, totalEdgeWt - vol);
    } else {
      return 0.0;
    }
  }