Returns the average KAM node in degree.

Zero is returned if the average is undefined (in case
the number of KAM nodes is zero).
6808
public double getAverageKamNodeInDegree(String kamName) {
        final int nodes = getKamNodeCount(kamName);
        return (nodes != 0 ? ((double) getKamEdgeCount(kamName)) / nodes : 0.0);
    }
656124
def accessible(self,fromstate, tostate):
        """"""
        if (not (fromstate in self.nodes)) or (not (tostate in self.nodes)) or not (fromstate in self.edges_out):
            return 0
        if tostate in self.edges_out[fromstate]:
            return self.edges_out[fromstate][tostate]
        else:
            return 0
1304162
private double preNorm(NumberVector v, final int start, final int end) {
    double agg = 0.;
    for(int d = start; d < end; d++) {
      final double xd = v.doubleValue(d);
      final double delta = xd >= 0. ? xd : -xd;
      agg += MathUtil.powi(delta, intp);
    }
    return agg;
  }
960055
def averageSize(self):
        """"""
        cm = self.centerOfMass()
        coords = self.coordinates(copy=False)
        if not len(coords):
            return 0
        s, c = 0.0, 0.0
        n = len(coords)
        step = int(n / 10000.0) + 1
        for i in np.arange(0, n, step):
            s += utils.mag(coords[i] - cm)
            c += 1
        return s / c
746987
def get_random_node(graph,
                    node_blacklist: Set[BaseEntity],
                    invert_degrees: Optional[bool] = None,
                    ) -> Optional[BaseEntity]:
    
    try:
        nodes, degrees = zip(*(
            (node, degree)
            for node, degree in sorted(graph.degree(), key=itemgetter(1))
            if node not in node_blacklist
        ))
    except ValueError:  # something wrong with graph, probably no elements in graph.degree_iter
        return

    if invert_degrees is None or invert_degrees:
        # More likely to choose low degree nodes to explore, so don't make hubs
        degrees = [1 / degree for degree in degrees]

    wrg = WeightedRandomGenerator(nodes, degrees)
    return wrg.next()
329774
def get_Sb(data):
    
    Sb, N = 0., 0.
    for rec in data:
        delta = 90. - abs(rec['vgp_lat'])
        if rec['average_k'] != 0:
            k = rec['average_k']
            L = rec['average_lat'] * np.pi / 180.  # latitude in radians
            Nsi = rec['average_nn']
            K = old_div(k, (2. * (1. + 3. * np.sin(L)**2) /
                            (5. - 3. * np.sin(L)**2)))
            Sw = old_div(81., np.sqrt(K))
        else:
            Sw, Nsi = 0, 1.
        Sb += delta**2. - old_div((Sw**2), Nsi)
        N += 1.
    return np.sqrt(old_div(Sb, float(N - 1.)))
570001
public long average()
    {
        double sum = 0;
        int count = 0;
        for (float d = 0 ; d <= 1.0d ; d += 0.02d)
        {
            sum += inverseCumProb(d);
            count += 1;
        }
        return (long) (sum / count);
    }
409007
@Override
    public double average()
    {
        readLock.lock();
        try
        {
            int count = count();
            double s = 0;
            double c = 0;
            PrimitiveIterator.OfInt it = modIterator();
            while (it.hasNext())
            {
                int m = it.nextInt();
                s += sin[m];
                c += cos[m];
            };
            return toDegrees(s / count, c / count);
        }
        finally
        {
            readLock.unlock();
        }
    }
314302
def _calculate_average(self, points):
        
        assert len(self.theta) == len(points), \
            "points has length %i, but should have length %i" % \
            (len(points), len(self.theta))
        new_point = {'x': 0, 'y': 0, 'time': 0}
        for key in new_point:
            new_point[key] = self.theta[0] * points[0][key] + \
                self.theta[1] * points[1][key] + \
                self.theta[2] * points[2][key]
        return new_point
108707
def calculate_average_diameter(self, **kwargs):
        
        self.average_diameter = find_average_diameter(
            self.elements, self.coordinates, **kwargs)
        return self.average_diameter
685933
function degreeCentrality(options) {
    options = defaults$1(options);
    var cy = this.cy();
    var callingEles = this;
    var _options = options,
        root = _options.root,
        weight = _options.weight,
        directed = _options.directed,
        alpha = _options.alpha;
    root = cy.collection(root)[0];

    if (!directed) {
      var connEdges = root.connectedEdges().intersection(callingEles);
      var k = connEdges.length;
      var s = 0; // Now, sum edge weights

      for (var i = 0; i < connEdges.length; i++) {
        s += weight(connEdges[i]);
      }

      return {
        degree: Math.pow(k, 1 - alpha) * Math.pow(s, alpha)
      };
    } else {
      var edges = root.connectedEdges();
      var incoming = edges.filter(function (edge) {
        return edge.target().same(root) && callingEles.has(edge);
      });
      var outgoing = edges.filter(function (edge) {
        return edge.source().same(root) && callingEles.has(edge);
      });
      var k_in = incoming.length;
      var k_out = outgoing.length;
      var s_in = 0;
      var s_out = 0; // Now, sum incoming edge weights

      for (var _i2 = 0; _i2 < incoming.length; _i2++) {
        s_in += weight(incoming[_i2]);
      } // Now, sum outgoing edge weights


      for (var _i3 = 0; _i3 < outgoing.length; _i3++) {
        s_out += weight(outgoing[_i3]);
      }

      return {
        indegree: Math.pow(k_in, 1 - alpha) * Math.pow(s_in, alpha),
        outdegree: Math.pow(k_out, 1 - alpha) * Math.pow(s_out, alpha)
      };
    }
  }
957826
def degree(self, vertex):
        
        try:
            return len(self.vertices[vertex])
        except KeyError:
            raise GraphInsertError("Vertex %s doesn't exist." % (vertex,))
247389
def calculate_epsilon_effective(rho, epsilon, seed_degree, neighbor_degrees, mean_degree):
    
    # Calculate a weighted neighborhood degree average.
    # neighborhood_degree = rho*seed_degree + (1-rho)*neighbor_degrees.mean()
    neighborhood_degree = neighbor_degrees.mean()

    # Calculate the seed neighborhood normalized effective epsilon.
    epsilon_effective = (epsilon*np.log(1 + seed_degree))/np.log(1 + neighborhood_degree)

    # Calculate the maximum epsilon for at least one push on a neighboring node.
    # Also the minimum epsilon for a push on all the neighboring nodes.
    epsilon_effective_maximum = np.max(1/(seed_degree*neighbor_degrees))
    epsilon_effective_minimum = np.min(1/(seed_degree*neighbor_degrees))

    # print(epsilon_effective, epsilon_effective_maximum, epsilon_effective_minimum)

    # The maximum epsilon is absolute, whereas we regularize for the minimum.
    if epsilon_effective > epsilon_effective_maximum:
        epsilon_effective = epsilon_effective_maximum
    elif epsilon_effective < epsilon_effective_minimum:
        epsilon_effective = (epsilon_effective_minimum + epsilon_effective)/2

    return epsilon_effective
814554
def average(var, key, N):
    ''''''
    global average_data
    if not key in average_data:
        average_data[key] = [var]*N
        return var
    average_data[key].pop(0)
    average_data[key].append(var)
    return sum(average_data[key])/N
508477
public float getNormalZ(int vertex) {
        if (!hasNormals()) {
            throw new IllegalStateException("mesh has no normals");
        }
        
        checkVertexIndexBounds(vertex);
        
        return m_normals.getFloat((vertex * 3 + 2) * SIZEOF_FLOAT);
    }
980771
Kam[] kams(KamNode... nodes) {
        List<Kam> kams = new ArrayList<Kam>(nodes.length);
        for (int i = 0; i < nodes.length; i++) {
            KamNode node = nodes[i];
            kams.add(node.getKam());
        }
        return kams.toArray(new Kam[0]);
    }
610069
protected long determineBalance(final IntervalTreeNode node) {
        if (node == null) {
            return 0L;
        }

        return (node.hasLeft() ? node.getLeft().getHeight() : 0) -
                (node.hasRight() ? node.getRight().getHeight() : 0);
    }