/** Stores an array to a file given by a pathname. * * @param array an array whose elements will be written to {@code filename}. * @param filename a filename. */ public static void storeLongs(final long array[], final CharSequence filename) throws IOException { storeLongs(array, 0, array.length, filename); } /** Stores the element returned by an iterator to a given print stream.
/** Stores an array to a given print stream. * * @param array an array whose elements will be written to {@code stream}. * @param stream a print stream. */ public static void storeLongs(final long array[], final PrintStream stream) { storeLongs(array, 0, array.length, stream); } /** Stores an array fragment to a file given by a {@link File} object.
/** Stores an array to a file given by a {@link File} object. * * @param array an array whose elements will be written to {@code filename}. * @param file a file. */ public static void storeLongs(final long array[], final File file) throws IOException { storeLongs(array, 0, array.length, file); } /** Stores an array to a file given by a pathname.
/** Stores an array fragment to a file given by a pathname. * * @param array an array whose elements will be written to {@code filename}. * @param offset the index of the first element of {@code array} to be written. * @param length the number of elements of {@code array} to be written. * @param filename a filename. */ public static void storeLongs(final long array[], final int offset, final int length, final CharSequence filename) throws IOException { storeLongs(array, offset, length, new File(filename.toString())); } /** Stores an array to a file given by a {@link File} object.
/** Stores the element returned by an iterator to a file given by a pathname. * * @param i an iterator whose output will be written to {@code filename}. * @param filename a filename. */ public static void storeLongs(final LongIterator i, final CharSequence filename) throws IOException { storeLongs(i, new File(filename.toString())); } /** Loads elements from a given fast buffered reader, storing them in a given big-array fragment.
/** Stores a big-array fragment to a file given by a pathname. * * @param array a big array whose elements will be written to {@code filename}. * @param offset the index of the first element of {@code array} to be written. * @param length the number of elements of {@code array} to be written. * @param filename a filename. */ public static void storeLongs(final long array[][], final long offset, final long length, final CharSequence filename) throws IOException { storeLongs(array, offset, length, new File(filename.toString())); } /** Stores a big array to a file given by a {@link File} object.
/** Stores a big array to a file given by a pathname. * * @param array a big array whose elements will be written to {@code filename}. * @param filename a filename. */ public static void storeLongs(final long array[][], final CharSequence filename) throws IOException { storeLongs(array, 0, it.unimi.dsi.fastutil.longs.LongBigArrays.length(array), filename); } /** A wrapper that exhibits the content of a reader as a type-specific iterator. */
/** Stores a big array to a file given by a {@link File} object. * * @param array a big array whose elements will be written to {@code filename}. * @param file a file. */ public static void storeLongs(final long array[][], final File file) throws IOException { storeLongs(array, 0, it.unimi.dsi.fastutil.longs.LongBigArrays.length(array), file); } /** Stores a big array to a file given by a pathname.
/** Stores a big array to a given print stream. * * @param array a big array whose elements will be written to {@code stream}. * @param stream a print stream. */ public static void storeLongs(final long array[][], final PrintStream stream) { storeLongs(array, 0, it.unimi.dsi.fastutil.longs.LongBigArrays.length(array), stream); } /** Stores a big-array fragment to a file given by a {@link File} object.
/** Stores a big-array fragment to a file given by a {@link File} object. * * @param array a big array whose elements will be written to {@code filename}. * @param offset the index of the first element of {@code array} to be written. * @param length the number of elements of {@code array} to be written. * @param file a file. */ public static void storeLongs(final long array[][], final long offset, final long length, final File file) throws IOException { final PrintStream stream = new PrintStream(new FastBufferedOutputStream(new FileOutputStream(file))); storeLongs(array, offset, length, stream); stream.close(); } /** Stores a big-array fragment to a file given by a pathname.
/** Stores the element returned by an iterator to a file given by a {@link File} object. * * @param i an iterator whose output will be written to {@code filename}. * @param file a file. */ public static void storeLongs(final LongIterator i, final File file) throws IOException { final PrintStream stream = new PrintStream(new FastBufferedOutputStream(new FileOutputStream(file))); storeLongs(i, stream); stream.close(); } /** Stores the element returned by an iterator to a file given by a pathname.
/** Stores an array fragment to a file given by a {@link File} object. * * @param array an array whose elements will be written to {@code filename}. * @param offset the index of the first element of {@code array} to be written. * @param length the number of elements of {@code array} to be written. * @param file a file. */ public static void storeLongs(final long array[], final int offset, final int length, final File file) throws IOException { final PrintStream stream = new PrintStream(new FastBufferedOutputStream(new FileOutputStream(file))); storeLongs(array, offset, length, stream); stream.close(); } /** Stores an array fragment to a file given by a pathname.
public static void main(String arg[]) throws IOException, JSAPException { SimpleJSAP jsap = new SimpleJSAP(NeighbourhoodFunction.class.getName(), "Prints the neighbourhood function of a graph, computing it via breadth-first visits.", new Parameter[] { new FlaggedOption("logInterval", JSAP.LONG_PARSER, Long.toString(ProgressLogger.DEFAULT_LOG_INTERVAL), JSAP.NOT_REQUIRED, 'l', "log-interval", "The minimum time interval between activity logs in milliseconds."), new Switch("expand", 'e', "expand", "Expand the graph to increase speed (no compression)."), new FlaggedOption("threads", JSAP.INTSIZE_PARSER, "0", JSAP.NOT_REQUIRED, 'T', "threads", "The number of threads to be used. If 0, the number will be estimated automatically. Note that if the graph is small a large number of thread will slow down the computation because of synchronization costs."), new UnflaggedOption("basename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The basename of the graph."), } ); JSAPResult jsapResult = jsap.parse(arg); if (jsap.messagePrinted()) System.exit(1); final String basename = jsapResult.getString("basename"); final int threads = jsapResult.getInt("threads"); ProgressLogger pl = new ProgressLogger(LOGGER, jsapResult.getLong("logInterval"), TimeUnit.MILLISECONDS); ImmutableGraph g =ImmutableGraph.load(basename); if (jsapResult.userSpecified("expand")) g = new ArrayListMutableGraph(g).immutableView(); TextIO.storeLongs(computeExact(g, threads, pl), System.out); } }