Package edu.ucla.sspace.util.primitive

Examples of edu.ucla.sspace.util.primitive.IntIterator.nextInt()


  }

        IntIterator iter = selected.iterator();
        DoubleVector[] centroids = new DoubleVector[k];
        for (int i = 0; iter.hasNext(); ++i)
            centroids[i] = dataPoints.getRowVector(iter.nextInt());
        return centroids;
    }

   
    private static IntPair pickFirstTwo(Matrix dataPoints,
View Full Code Here


    public static <E extends Edge, G extends Graph<E>> Graph<Edge>
            toLineGraph(G graph, Indexer<E> edgeIndices) {
        Graph<Edge> lineGraph = new SparseUndirectedGraph();
        IntIterator verts = graph.vertices().iterator();
        while (verts.hasNext()) {
            int v = verts.nextInt();
            Set<E> adjacent = graph.getAdjacencyList(v);
            // For each pair of edges connected to the same vertex, add them as
            // vertices in the line graph and connect them by an edge
            for (E e1 : adjacent) {
                int e1vertex = edgeIndices.index(e1);
View Full Code Here

        IntSet neighbors = g.getNeighbors(v);
        IntIterator iter = neighbors.iterator();
        Counter<Integer> classes = new ObjectCounter<Integer>();
        classes.count(vertexAssignments[v]);
        while (iter.hasNext()) {
            int n = iter.nextInt();
            classes.count(vertexAssignments[n]);
        }

        TIntSet ties = new TIntHashSet();
        int max = 0;
View Full Code Here

                                    j, fac.centerOfMass());
                       
                        int clusterId = j;
                        IntIterator iter = fac.indices().iterator();
                        while (iter.hasNext()) {
                            int row = iter.nextInt();
                            assignments[row] =
                                new HardAssignment(clusterId);
                        }
                    }
                    return new Assignments(numClusters, assignments, matrix);                   
View Full Code Here

                                    j, fac.centerOfMass());
                       
                        int clusterId = facilityAssignments[j];
                        IntIterator iter = fac.indices().iterator();
                        while (iter.hasNext()) {
                            int row = iter.nextInt();
                            assignments[row] =
                                new HardAssignment(clusterId);
                        }
                    }
                    return new Assignments(numClusters, assignments, matrix);
View Full Code Here

                "Vertices must be in continugous order");
       
        double[] centralities = new double[g.order()];
        IntIterator vertexIter = g.vertices().iterator();
        while (vertexIter.hasNext()) {
            int s = vertexIter.nextInt();
            Deque<Integer> S = new ArrayDeque<Integer>();

            // Initialize P to an empty list for each vertex
            List<List<Integer>> P = new ArrayList<List<Integer>>(g.order());
            for (int i = 0; i < g.order(); ++i)
View Full Code Here

            while (!Q.isEmpty()) {
                int v = Q.poll();
                S.offer(v);
                IntIterator neighborIter = g.getNeighbors(v).iterator();
                while (neighborIter.hasNext()) {
                    int w = neighborIter.nextInt();
                    // Check whether this is the first time we've seen vertex w
                    if (d[w] < 0) {
                        Q.offer(w);
                        d[w] = d[v] + 1;
                    }
View Full Code Here

        PrintWriter pw = new PrintWriter(f);
        pw.println("*Vertices " + g.order());
        if (vertexLabels != null) {
            IntIterator iter = g.vertices().iterator();
            while (iter.hasNext()) {
                int v = iter.nextInt();
                String label = vertexLabels.lookup(v);
                if (label != null)
                    pw.printf("%d \"%s\"%n", v, label);
            }
        }
View Full Code Here

        // iterative over the edges to see how many unique compacted edges there
        // are.  We need to know the number for the pajek formatting
        pw.println("*Edges");
        IntIterator iter = g.vertices().iterator();
        while (iter.hasNext()) {
            int v1 = iter.nextInt();
            IntIterator iter2 = g.getNeighbors(v1).iterator();
            while (iter2.hasNext()) {
                int v2 = iter2.nextInt();
                if (v1 < v2)
                    continue;
View Full Code Here

        IntIterator iter = g.vertices().iterator();
        while (iter.hasNext()) {
            int v1 = iter.nextInt();
            IntIterator iter2 = g.getNeighbors(v1).iterator();
            while (iter2.hasNext()) {
                int v2 = iter2.nextInt();
                if (v1 < v2)
                    continue;
                Set<? extends WeightedEdge> edges = g.getEdges(v1, v2);
                double fromWeight = 0;
                double toWeight = 0;
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.