The total number of edges (or sum of weights) to node ``v`` from
    community ``comm``.

    See Also
    --------
    :func:`~VertexPartition.MutableVertexPartition.weight_to_comm`
973686
def weight_from_comm(self, v, comm):
    
    return _c_louvain._MutableVertexPartition_weight_from_comm(self._partition, v, comm)
1226890
def _calc_size_stats(self):
        
        self.total_records = 0
        self.total_length = 0
        self.total_nodes = 0
        if type(self.content['data']) is dict:
            self.total_length += len(str(self.content['data']))
            self.total_records += 1
            self.total_nodes = sum(len(x) for x in self.content['data'].values())
                               
        elif hasattr(self.content['data'], '__iter__') and type(self.content['data']) is not str:
            self._get_size_recursive(self.content['data'])
        else:
            self.total_records += 1
            self.total_length += len(str(self.content['data']))
            
        return str(self.total_records) + ' records [or ' +  str(self.total_nodes) + ' nodes], taking ' + str(self.total_length) + ' bytes'
1086750
def parse_cluster_pubsub_numpat(res, **options):
    
    aggregate = options.get('aggregate', True)
    if not aggregate:
        return res

    numpat = 0
    for node, node_numpat in res.items():
        numpat += node_numpat
    return numpat
1098849
def number_of_links(neighbors, datapoints, x, y)
      (0..datapoints.size-1).map do |i|
        neighbors.lookup(x,i) * neighbors.lookup(i,y)
      end.inject(0) {|m,v| m+v}
    end
1076434
function calcCutValue(t, g, child) {
  var childLab = t.node(child);
  var parent = childLab.parent;
  // True if the child is on the tail end of the edge in the directed graph
  var childIsTail = true;
  // The graph's view of the tree edge we're inspecting
  var graphEdge = g.edge(child, parent);
  // The accumulated cut value for the edge between this node and its parent
  var cutValue = 0;

  if (!graphEdge) {
    childIsTail = false;
    graphEdge = g.edge(parent, child);
  }

  cutValue = graphEdge.weight;

  _.forEach(g.nodeEdges(child), function(e) {
    var isOutEdge = e.v === child,
      other = isOutEdge ? e.w : e.v;

    if (other !== parent) {
      var pointsToHead = isOutEdge === childIsTail,
        otherWeight = g.edge(e).weight;

      cutValue += pointsToHead ? otherWeight : -otherWeight;
      if (isTreeEdge(t, child, other)) {
        var otherCutValue = t.edge(child, other).cutvalue;
        cutValue += pointsToHead ? -otherCutValue : otherCutValue;
      }
    }
  });

  return cutValue;
}
256665
def sum(self, weights=None):
        
        if weights is None:
            weights = self.data.weights
        return utils.bincount(self.labels, weights, self.N)
706116
def get_report(self):
    
    ostr = ''
    ostr += "Nodes: "+str(len(self.__nodes.keys()))+"\n"
    ostr += "Edges: "+str(len(self.__edges.keys()))+"\n"
    return ostr
1011165
@Override
    public float calculatePriority(int node) {
        CalcShortcutsResult calcShortcutsResult = calcShortcutCount(node);

        // # huge influence: the bigger the less shortcuts gets created and the faster is the preparation
        //
        // every adjNode has an 'original edge' number associated. initially it is r=1
        // when a new shortcut is introduced then r of the associated edges is summed up:
        // r(u,w)=r(u,v)+r(v,w) now we can define
        // originalEdgesCount = σ(v) := sum_{ (u,w) ∈ shortcuts(v) } of r(u, w)
        int originalEdgesCount = calcShortcutsResult.originalEdgesCount;

        // # lowest influence on preparation speed or shortcut creation count
        // (but according to paper should speed up queries)
        //
        // number of already contracted neighbors of v
        int contractedNeighbors = 0;
        int degree = 0;
        CHEdgeIterator iter = remainingEdgeExplorer.setBaseNode(node);
        while (iter.next()) {
            degree++;
            if (iter.isShortcut())
                contractedNeighbors++;
        }

        // from shortcuts we can compute the edgeDifference
        // # low influence: with it the shortcut creation is slightly faster
        //
        // |shortcuts(v)| − |{(u, v) | v uncontracted}| − |{(v, w) | v uncontracted}|
        // meanDegree is used instead of outDegree+inDegree as if one adjNode is in both directions
        // only one bucket memory is used. Additionally one shortcut could also stand for two directions.
        int edgeDifference = calcShortcutsResult.shortcutsCount - degree;

        // according to the paper do a simple linear combination of the properties to get the priority.
        return params.edgeDifferenceWeight * edgeDifference +
                params.originalEdgesCountWeight * originalEdgesCount +
                params.contractedNeighborsWeight * contractedNeighbors;
    }
571733
def edge_number(self) -> int:
        """"""
        edges = set()
        for node, succs in self.edges.items():
            for succ in succs:
                edges.add(frozenset((node, succ)))
        return len(edges)
466843
def complete_sum(self):
        
        node = self.node.complete_sum()
        if node is self.node:
            return self
        else:
            return _expr(node)
109973
def _topological_sort(self):
        
        sorted_graph = []
        node_map = self._graph.get_nodes()

        nodes = [NodeVisitor(node_map[node]) for node in node_map]

        def get_pointers_for_edge_nodes(visitor_decorated_node):
            edges = []
            edge_ids = visitor_decorated_node.get_node().get_edges()
            for node in nodes:
                if node.get_id() in edge_ids:
                    edges.append(node)

            return edges

        # node is initially weighted with the number of immediate dependencies
        for node in nodes:
            for edge in get_pointers_for_edge_nodes(node):
                edge.increment()

        # Start with a list of nodes who have no dependents
        resolved = [node for node in nodes if node.get_weight() == 0]

        while resolved:
            node = resolved.pop()
            sorted_graph.append(node)

            for edge in get_pointers_for_edge_nodes(node):
                edge.decrement()
                if edge.get_weight() == 0:
                    resolved.append(edge)

        self._circular_dependencies = [
            node.get_node() for node in nodes if node.get_weight() > 0]

        self._sorted_nodes = list(reversed(
            [node.get_node() for node in sorted_graph]))
628969
def count_passed_node_filter(graph: BELGraph, node_predicates: NodePredicates) -> int:
    """"""
    return sum(1 for _ in filter_nodes(graph, node_predicates=node_predicates))
1089308
def nx_minimum_weight_component(graph, weight='weight'):
    
    mwc = nx.minimum_spanning_tree(graph, weight=weight)
    # negative edges only reduce the total weight
    neg_edges = (e for e, w in nx_gen_edge_attrs(graph, weight) if w < 0)
    mwc.add_edges_from(neg_edges)
    return mwc
660016
def inspect
      edge_count = @nodes.values.each_with_object(Set.new) do |node, edges|
        edges.merge(node.edges(:out))
      end.length

      "#<#{self.class} (#{ @nodes.length } nodes, #{ edge_count } edges)>"
    end
854852
function getSubjectBarycenter(subject){

	var weighted_number_of_edges = 0;
	var number_of_edges = 0;
	for( var o = 1; o <= object_vector.length; o++ ){
	    if( relation_matrix[object_vector[o -1].id()] &&
		relation_matrix[object_vector[o -1].id()][subject.id()]){
		weighted_number_of_edges += o;
		number_of_edges++;
	    }
	}
	// The '-1' is to offset the indexing.
	return ( weighted_number_of_edges / number_of_edges ) -1;
    }
1221801
def count(self):
        ""
        if self._nodes is None:
            return 1
        return sum(i.count() for i in self._nodes)
1073938
def _neighbors(self,v):
        
        assert self.layout.dag
        dirv = self.layout.dirv
        grxv = self.layout.grx[v]
        try: #(cache)
            return grxv.nvs[dirv]
        except AttributeError:
            grxv.nvs={-1:v.N(-1),+1:v.N(+1)}
            if grxv.dummy: return grxv.nvs[dirv]
            # v is real, v.N are graph neigbors but we need layers neighbors
            for d in (-1,+1):
                tr=grxv.rank+d
                for i,x in enumerate(v.N(d)):
                    if self.layout.grx[x].rank==tr:continue
                    e=v.e_with(x)
                    dum = self.layout.ctrls[e][tr]
                    grxv.nvs[d][i]=dum
            return grxv.nvs[dirv]