Package java.io

Examples of java.io.PrintWriter.printf()


            int numRows = Integer.parseInt(rowColNonZeroCount[0]);
            int numCols = Integer.parseInt(rowColNonZeroCount[1]);
            int numTotalNonZeros = Integer.parseInt(rowColNonZeroCount[2]);

            // Write out the header for the new matrix file.
            writer.printf("%d %d %d\n", numRows, numCols, numTotalNonZeros);

            line = br.readLine();
            // Traverse each column in the matrix.
            for (int col = 0; line != null && col < numCols; ++col) {
                int numNonZeros = Integer.parseInt(line);
View Full Code Here


            line = br.readLine();
            // Traverse each column in the matrix.
            for (int col = 0; line != null && col < numCols; ++col) {
                int numNonZeros = Integer.parseInt(line);
                writer.printf("%d\n", numNonZeros);

                // Transform each of the non zero values for the new matrix
                // file.
                for (int index = 0; (line = br.readLine()) != null &&
                                    index < numNonZeros; ++index) {
View Full Code Here

                for (int index = 0; (line = br.readLine()) != null &&
                                    index < numNonZeros; ++index) {
                    String[] rowValue = line.split("\\s+");
                    int row = Integer.parseInt(rowValue[0]);
                    double value = Double.parseDouble(rowValue[1]);
                    writer.printf("%d %f\n", row,
                                  transform.transform(row, col, value));
                }
            }

            writer.close();
View Full Code Here

                v1 = String.valueOf(e.from());
            String v2 = vertexLabels.lookup(e.to());
            if (v2 == null)
                v2 = String.valueOf(e.to());

            pw.printf("%s\t%s%n", v1, v2);
        }
        pw.close();
    }

    public static DirectedGraph<DirectedEdge> readDirected(File f) throws IOException {
View Full Code Here

    public static <T> void writeUndirectedMultigraph(
            Multigraph<T,TypedEdge<T>> g, File f) throws IOException {
        PrintWriter pw = new PrintWriter(f);
        for (TypedEdge<T> e : g.edges()) {
            pw.printf("%d %d %f%n", e.from(), e.to(), e.edgeType());
        }
        pw.close();       
    }

    public static <T> void writeUndirectedMultigraph(
View Full Code Here

                DoubleVector row = input.getRowVector(i);
                for (int n : neighborMap.values()) {
                    double edgeWeight = kernelSim.sim(
                            row, input.getRowVector(n));
                    affMatrixWriter.printf("%d %d %f\n", i+1 ,n+1, edgeWeight);
                }
            }

            // Finish writing the affinity matrix so it can be sent to matlab
            affMatrixWriter.close();   
View Full Code Here

                // If using k-nearest neighbors, once the row has been
                // processed, report all the k-nearest as being adjacent
                // Note that the two rows may not have a symmetric
                // connection so only one value needs to be written
                for (Duple<Integer,Double> t : neighbors.values())
                    affMatrixWriter.printf("%d %d %f\n", row+1, t.x+1, t.y);
            }

            // Finish writing the matrix
            affMatrixWriter.close();
            return new MatrixFile(affMatrixFile, MatrixIO.Format.MATLAB_SPARSE);
View Full Code Here

                             motifToZScore.entrySet()) {
                        File dotFile = new File(baseDir, "graph-" + (graphNum++) + ".dot");
                        dio.writeDirectedMultigraph(e.getKey(), dotFile, edgeColors);
                        String imgFile = dotFile.getName();
                        imgFile = imgFile.substring(0, imgFile.length() - 3) + "gif";
                        imgScript.printf("dot -Tgif %s -o %s%n", dotFile.getName(), imgFile);
                        int count = e.getValue().count;
                        double zScore = e.getValue().statistic;
                        double mean = e.getValue().meanCountInNullModel;
                        double stddev = e.getValue().stddevInNullModel;
                        pw.printf("  <tr><td><img src=\"%s\"></td><td>%d</td><td>%f</td><td>%f</td><td>%f</td></tr>%n",
View Full Code Here

                             motifToZScore.entrySet()) {
                        File dotFile = new File(baseDir, "graph-" + (graphNum++) + ".dot");
                        dio.writeUndirectedMultigraph(e.getKey(), dotFile, edgeColors);
                        String imgFile = dotFile.getName();
                        imgFile = imgFile.substring(0, imgFile.length() - 3) + "gif";
                        imgScript.printf("dot -Tgif %s -o %s%n", dotFile.getName(), imgFile);
                        int count = e.getValue().count;
                        double zScore = e.getValue().statistic;
                        double mean = e.getValue().meanCountInNullModel;
                        double stddev = e.getValue().stddevInNullModel;
                        pw.printf("  <tr><td><img src=\"%s\"></td><td>%d</td><td>%f</td><td>%f</td><td>%f</td></tr>%n",
View Full Code Here

    public static <T> void writeUndirectedMultigraph(
            Multigraph<T,TypedEdge<T>> g, File f,
            Indexer<String> vertexLabels) throws IOException {
        PrintWriter pw = new PrintWriter(f);
        for (TypedEdge<T> e : g.edges()) {
            pw.printf("%d %d %f%n", vertexLabels.lookup(e.from()),
                      vertexLabels.lookup(e.to()), e.edgeType());
        }
        pw.close();       
    }
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.