Connection cost matrix
347095
function (callback) {
            loadArrayBuffer(path.join(dic_path, "cc.dat.gz"), function (err, buffer) {
                if(err) {
                    return callback(err);
                }
                var cc_buffer = new Int16Array(buffer);
                dic.loadConnectionCosts(cc_buffer);
                callback(null);
            });
        }
205768
def initialize_connections(self):
        
        n, m = self.connections.visible_to_hidden.shape
        self.connections.visible_to_hidden = np.zeros((n, m))

        for i in range(n):
            random_vector = self._random.rand(m)
            # norm          = np.sqrt( np.sum(random_vector * random_vector) )
            self.connections.visible_to_hidden[i]  = random_vector
896948
def bandwidth(self):
    """"""
    return np.abs(np.diff(self.pairs(), axis=1)).max()
290987
public void computeMST(double[][] costs, UndirectedGraph graph) throws ContradictionException {
		g = graph;
		ma = propHK.getMandatoryArcsList();
		sortArcs(costs);
		treeCost = 0;
		cctRoot = n - 1;
		int tSize = addMandatoryArcs();
		connectMST(tSize);
	}
451525
public List<Link> connect(int bandwidth, Switch sw, Node... nodes) {
        List<Link> l = new ArrayList<>();
        for (Node n : nodes) {
            l.add(connect(bandwidth, sw, n));
        }
        return l;
    }
174072
def _d2f(self, x):
        
        d2f_dPg2 = lil_matrix((self._ng, 1)) # w.r.t p.u. Pg
        d2f_dQg2 = lil_matrix((self._ng, 1)) # w.r.t p.u. Qg]

        for i in self._ipol:
            p_cost = list(self._gn[i].p_cost)
            d2f_dPg2[i, 0] = polyval(polyder(p_cost, 2),
                self._Pg.v0[i] * self._base_mva) * self._base_mva**2
#            for i in ipol:
#                d2f_dQg2[i] = polyval(polyder(list(gn[i].p_cost), 2),
#                                      Qg.v0[i] * base_mva) * base_mva**2

        i = r_[range(self._Pg.i1, self._Pg.iN + 1),
               range(self._Qg.i1, self._Qg.iN + 1)]

        d2f = csr_matrix((vstack([d2f_dPg2, d2f_dQg2]).toarray().flatten(),
                          (i, i)), shape=(self._nxyz, self._nxyz))
        return d2f
331759
private double cost(DMatrixRMaj param )
    {
        function.compute(param, residuals);

        double error = NormOps_DDRM.normF(residuals);

        return error*error / (double)residuals.numRows;
    }
1197494
def solve_assignement(self, costs):
        
        if costs is None or len(costs) == 0:
            return dict()

        n = costs.shape[0]

        pairs = [(i, j) for i in range(0, n) for j in range(0, n) if costs[i, j] < invalid_match]

        costs_list = [costs[i, j] for (i, j) in pairs]

        assignment = lapjv.lapjv(list(zip(*pairs))[0], list(zip(*pairs))[1], costs_list)

        indexes = enumerate(list(assignment[0]))

        return dict([(row, col) for row, col in indexes])
506138
def cost(self, i, j):
        """"""
        return dist(self.endpoints[i][1], self.endpoints[j][0])
594533
def list_fees(location_id, opts = {})
      data, _status_code, _headers = list_fees_with_http_info(location_id, opts)
      return data
    end
221915
private void calculateDelays( int k, double[] cDelays, double[][] net )

    {

        double t;
        int ind, r = 1;
        for( int j = 0; j < net.length; ++j ) {
            t = 0;
            r = 1;
            ind = (int) net[j][0];
            /*
             * Area k is not included in delays
             */
            while( networkPipes[ind].getIndexPipeWhereDrain() != k ) {
                ind = networkPipes[ind].getIndexPipeWhereDrain();
                t += cDelays[ind];
                r++;
            }

            if (r > networkPipes.length) {
                pm.errorMessage(msg.message("trentoP.error.incorrectmatrix"));
                throw new ArithmeticException(msg.message("trentoP.error.incorrectmatrix"));
            }
            net[j][2] = t;
        }

    }
1080441
def matrix_undirected_weighted(user, interaction=None):
    
    matrix = _interaction_matrix(user, interaction=interaction)
    result = [[0 for _ in range(len(matrix))] for _ in range(len(matrix))]

    for a in range(len(matrix)):
        for b in range(len(matrix)):
            if a != b and matrix[a][b] and matrix[b][a]:
                result[a][b] = matrix[a][b] + matrix[b][a]
            elif matrix[a][b] is None or matrix[b][a] is None:
                result[a][b] = None
            else:
                result[a][b] = 0

    return result
542649
private void calculateGTClusterConnections(){
        for (int c0 = 0; c0 < gt0Clusters.size(); c0++) {
            for (int c1 = 0; c1 < gt0Clusters.size(); c1++) {
                    gt0Clusters.get(c0).calculateClusterConnection(c1, true);
            }
        }

        boolean changedConnection = true;
        while(changedConnection){
            if(debug){
                System.out.println("Cluster Connection");
                for (int c = 0; c < gt0Clusters.size(); c++) {
                    System.out.print("C"+gt0Clusters.get(c).label+" --> ");
                    for (int c1 = 0; c1 < gt0Clusters.get(c).connections.size(); c1++) {
                        System.out.print(" C"+gt0Clusters.get(c1).label+": "+gt0Clusters.get(c).connections.get(c1));
                    }
                    System.out.println("");
                }
                System.out.println("");
            }

            double max = 0;
            int maxIndexI = -1;
            int maxIndexJ = -1;

            changedConnection = false;
            for (int c0 = 0; c0 < gt0Clusters.size(); c0++) {
                for (int c1 = c0+1; c1 < gt0Clusters.size(); c1++) {
                    if(c0==c1) continue;
                        double min =Math.min(gt0Clusters.get(c0).connections.get(c1), gt0Clusters.get(c1).connections.get(c0));
                        if(min > max){
                            max = min;
                            maxIndexI = c0;
                            maxIndexJ = c1;
                        }
                }
            }
            if(maxIndexI!=-1 && max > tauConnection){
                gt0Clusters.get(maxIndexI).mergeCluster(maxIndexJ);
                if(debug)
                    System.out.println("Merging "+maxIndexI+" and "+maxIndexJ+" because of connection "+max);

                changedConnection = true;
            }
        }
        numGT0Classes = gt0Clusters.size();
    }
312622
def connections( self, cls = None ):
        
        scene = self.scene()
        if ( not scene ):
            return []
        
        if ( not cls ):
            cls = XNodeConnection
        
        output = []
        for item in scene.items():
            if ( not isinstance(item, cls) ):
                continue
            
            if ( item.inputNode() == self or item.outputNode() == self ):
                output.append(item)
        
        return output
1253465
private static List<Vertex> dijkstra(Graph graph)
    {
        List<Vertex> resultList = new LinkedList<Vertex>();
        Vertex[] vertexes = graph.getVertexes();
        List<EdgeFrom>[] edgesTo = graph.getEdgesTo();
        double[] d = new double[vertexes.length];
        Arrays.fill(d, Double.MAX_VALUE);
        d[d.length - 1] = 0;
        int[] path = new int[vertexes.length];
        Arrays.fill(path, -1);
        PriorityQueue<State> que = new PriorityQueue<State>();
        que.add(new State(0, vertexes.length - 1));
        while (!que.isEmpty())
        {
            State p = que.poll();
            if (d[p.vertex] < p.cost) continue;
            for (EdgeFrom edgeFrom : edgesTo[p.vertex])
            {
                if (d[edgeFrom.from] > d[p.vertex] + edgeFrom.weight)
                {
                    d[edgeFrom.from] = d[p.vertex] + edgeFrom.weight;
                    que.add(new State(d[edgeFrom.from], edgeFrom.from));
                    path[edgeFrom.from] = p.vertex;
                }
            }
        }
        for (int t = 0; t != -1; t = path[t])
        {
            resultList.add(vertexes[t]);
        }
        return resultList;
    }
545209
private static void eltran(DenseMatrix A, DenseMatrix V, int[] perm) {
        int n = A.nrows();
        for (int mp = n - 2; mp > 0; mp--) {
            for (int k = mp + 1; k < n; k++) {
                V.set(k, mp, A.get(k, mp - 1));
            }
            int i = perm[mp];
            if (i != mp) {
                for (int j = mp; j < n; j++) {
                    V.set(mp, j, V.get(i, j));
                    V.set(i, j, 0.0);
                }
                V.set(i, mp, 1.0);
            }
        }
    }
398050
def network(n):
    
    tpm(n.tpm)
    connectivity_matrix(n.cm)
    if n.cm.shape[0] != n.size:
        raise ValueError("Connectivity matrix must be NxN, where N is the "
                         "number of nodes in the network.")
    return True