本文整理汇总了Java中com.martiansoftware.jsap.JSAPResult.getBoolean方法的典型用法代码示例。如果您正苦于以下问题:Java JSAPResult.getBoolean方法的具体用法?Java JSAPResult.getBoolean怎么用?Java JSAPResult.getBoolean使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.martiansoftware.jsap.JSAPResult
的用法示例。
在下文中一共展示了JSAPResult.getBoolean方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException, JSAPException {
SimpleJSAP jsap = new SimpleJSAP(GZIPArchiveReader.class.getName(), "Writes some random records on disk.",
new Parameter[] {
new Switch("fully", 'f', "fully",
"Whether to read fully the record (and do a minimal cosnsistency check)."),
new UnflaggedOption("path", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY,
"The path to read from."), });
JSAPResult jsapResult = jsap.parse(args);
if (jsap.messagePrinted())
System.exit(1);
final boolean fully = jsapResult.getBoolean("fully");
GZIPArchiveReader gzar = new GZIPArchiveReader(new FileInputStream(jsapResult.getString("path")));
for (;;) {
ReadEntry e = gzar.getEntry();
if (e == null)
break;
InputStream inflater = e.lazyInflater.get();
if (fully)
ByteStreams.toByteArray(inflater);
e.lazyInflater.consume();
System.out.println(e);
}
}
示例2: main
import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
public static void main( String arg[] ) throws IOException, JSAPException, IllegalArgumentException, ClassNotFoundException, IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchMethodException {
SimpleJSAP jsap = new SimpleJSAP( SequentialHyperBall.class.getName(), "Prints an approximation of the neighbourhood function.",
new Parameter[] {
new FlaggedOption( "log2m", JSAP.INTEGER_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'l', "log2m", "The logarithm of the number of registers." ),
new FlaggedOption( "upperBound", JSAP.LONGSIZE_PARSER, Long.toString( Long.MAX_VALUE ), JSAP.NOT_REQUIRED, 'u', "upper-bound", "An upper bound to the number of iteration (default: the graph size)." ),
new FlaggedOption( "threshold", JSAP.DOUBLE_PARSER, Double.toString( 1E-3 ), JSAP.NOT_REQUIRED, 't', "threshould", "A threshould that will be used to stop the computation by absolute or relative increment." ),
new Switch( "spec", 's', "spec", "The source is not a basename but rather a specification of the form <ImmutableGraphImplementation>(arg,arg,...)." ),
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 boolean spec = jsapResult.getBoolean( "spec" );
final String basename = jsapResult.getString( "basename" );
final ProgressLogger pl = new ProgressLogger( LOGGER );
final int log2m = jsapResult.getInt( "log2m" );
final ImmutableGraph graph = spec ? ObjectParser.fromSpec( basename, ImmutableGraph.class, GraphClassParser.PACKAGE ) : ImmutableGraph.loadOffline( basename );
SequentialHyperBall shb = new SequentialHyperBall( graph, log2m, pl, Util.randomSeed() );
TextIO.storeDoubles( shb.approximateNeighbourhoodFunction( jsapResult.getLong( "upperBound" ), jsapResult.getDouble( "threshold" ) ), System.out );
shb.close();
}
示例3: main
import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
public static void main( String arg[] ) throws IOException, JSAPException, IllegalArgumentException, ClassNotFoundException, IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchMethodException {
SimpleJSAP jsap = new SimpleJSAP( ExactNeighbourhoodFunction.class.getName(), "Prints the neighbourhood function.",
new Parameter[] {
new Switch( "spec", 's', "spec", "The source is not a basename but rather a specification of the form <ImmutableGraphImplementation>(arg,arg,...)." ),
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 boolean spec = jsapResult.getBoolean( "spec" );
final String basename = jsapResult.getString( "basename" );
final ProgressLogger pl = new ProgressLogger( LOGGER );
final ImmutableGraph graph = spec ? ObjectParser.fromSpec( basename, ImmutableGraph.class, GraphClassParser.PACKAGE ) : ImmutableGraph.loadOffline( basename );
final ExactNeighbourhoodFunction neighbourhoodFunction = new ExactNeighbourhoodFunction( graph, pl );
pl.start( "Computing..." );
TextIO.storeDoubles( neighbourhoodFunction.neighbourhoodFunction(), System.out );
pl.done();
}
示例4: processArgs
import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
private void processArgs(JSAPResult options) throws PEException {
displayVersion = options.getBoolean("version");
suppressWelcome = options.getBoolean("suppressWelcome");
emulateReader = options.getBoolean("emulateReader");
final String filename = options.getString("file");
final String cmd = options.getString("cmd");
if (filename != null) {
try {
fileInputStream = new FileInputStream(filename);
} catch (final Exception e) {
throw new PEException("Failed to open file '" + filename + "'", e);
}
} else if (cmd != null) {
singleCommand = cmd;
}
}
示例5: createGUI
import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
/**
* Create the GUI after the simulator has been initialize
*
* @param parserConfig
*/
public void createGUI(JSAPResult parserConfig) {
// create the GUI if the user asked for it
if (parserConfig.getBoolean("graphics")) {
gui = new SpaceSettlersGUI(simConfig, this);
}
}
示例6: main
import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
public static void main(String[] args) throws JSAPException, IOException, InterruptedException {
final SimpleJSAP jsap = new SimpleJSAP(RandomReadWritesTest.class.getName(), "Writes some random records on disk.",
new Parameter[] {
new FlaggedOption("random", JSAP.INTEGER_PARSER, "100", JSAP.NOT_REQUIRED, 'r', "random", "The number of random record to sample from."),
new FlaggedOption("body", JSAP.INTSIZE_PARSER, "4K", JSAP.NOT_REQUIRED, 'b', "body", "The maximum size of the random generated body (in bytes)."),
new Switch("fully", 'f', "fully", "Whether to read fully the record (and do a minimal sequential cosnsistency check)."),
new Switch("writeonly", 'w', "writeonly", "Whether to skip the read part (if present, 'fully' will be ignored."),
new UnflaggedOption("path", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The path to write to."),
new UnflaggedOption("records", JSAP.INTSIZE_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The numer of records to write."),
});
final JSAPResult jsapResult = jsap.parse(args);
if (jsap.messagePrinted()) System.exit(1);
final String path = jsapResult.getString("path");
final boolean compress = path.endsWith(".gz");
final boolean fully = jsapResult.getBoolean("fully");
final int parallel = compress ? 1 : 0;
final int body = jsapResult.getInt("body");
final WarcRecord[] rnd = prepareRndRecords(jsapResult.getInt("random"), RESPONSE_PROBABILITY, MAX_NUMBER_OF_HEADERS, MAX_LENGTH_OF_HEADER, body);
final int[] sequence = writeRecords(path, jsapResult.getInt("records"), rnd, parallel);
if (! jsapResult.getBoolean("writeonly"))
readRecords(path, sequence, body, fully, compress);
}
示例7: main
import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
public static void main(String[] rawArguments) throws Exception {
SimpleJSAP jsap = new SimpleJSAP(
WikipediaTextArchiveProducer.class.getName(),
"Build wikipedia graph.",
new Parameter[] {
new UnflaggedOption( "input", JSAP.STRING_PARSER, JSAP.REQUIRED,
"The pages-articles.xml input file, from Wikipedia." ),
new Switch("bzip", 'z', "bzip", "Interpret the input file as bzipped"),
new UnflaggedOption( "resolver", JSAP.STRING_PARSER, JSAP.REQUIRED,
"resolver" ),
new UnflaggedOption( "output", JSAP.STRING_PARSER, JSAP.REQUIRED,
"output graph basename" )
});
JSAPResult args = jsap.parse( rawArguments );
if ( jsap.messagePrinted() ) System.exit( 1 );
WikipediaDocumentSequence wikipediaDocumentSequence = new WikipediaDocumentSequence(
args.getString("input"),
args.getBoolean("bzip"),
"http://en.wikipedia.org/wiki/",
true, // parse text article
false // do not keep all namespaces
);
DocumentSequenceImmutableGraph g = new DocumentSequenceImmutableGraph(
wikipediaDocumentSequence,
8, // should be the anchor field
(VirtualDocumentResolver) SerializationUtils.read(args.getString("resolver"))
);
BVGraph.store(g, args.getString("output"));
}
示例8: main
import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
public static void main(String[] rawArguments) throws Exception {
SimpleJSAP jsap = new SimpleJSAP(
WikipediaCategoryProducer.class.getName(),
"Read a wikipedia dump and produces 3 files with " +
"serialized Java objects: \n" +
" * pageId2Name.ser, an Int2ObjectMap from page ids to " +
"wikipedia page names \n" +
" * catName2Id.ser, an Object2IntMap from category ids to " +
"category names \n" +
" * page2cat.ser, an Int2ObjectMap from page ids to an IntSet" +
"of category ids",
new Parameter[] {
new UnflaggedOption( "input", JSAP.STRING_PARSER, JSAP.REQUIRED,
"The pages-articles.xml input file, from Wikipedia." ),
new UnflaggedOption( "basename", JSAP.STRING_PARSER, JSAP.REQUIRED,
"The basename of the output files (p.e. a Directory with / in the end)" ),
new Switch("bzip", 'z', "bzip", "Interpret the input file as bzipped"),
new Switch("verbose", 'v', "verbose", "Print every category found to StdErr")
});
// Initializing input read
JSAPResult args = jsap.parse( rawArguments );
if ( jsap.messagePrinted() ) System.exit( 1 );
WikipediaDocumentSequence wikipediaDocumentSequence = new WikipediaDocumentSequence(
args.getString("input"),
args.getBoolean("bzip"),
"http://en.wikipedia.org/wiki/", true,
true // keep all namespaces
);
WikipediaCategoryProducer reader =
new WikipediaCategoryProducer(wikipediaDocumentSequence);
reader.setPlainUrisFile(args.getString("basename") + "pages.uris");
reader.extractAllData();
reader.saveAllTo(args.getString("basename"));
}
示例9: Parameters
import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
public Parameters(String[] args) throws JSAPException {
JSAP jsap = createJSAP();
JSAPResult config = jsap.parse(args);
if(!config.success()){
exit(jsap);
}
input = config.getString(INPUT_OPT);
output = config.getString(OUTPUT_OPT);
model = config.getString(MODEL_OPT);
train = config.getString(TRAIN_OPT);
external = config.getString(EXTERNAL_OPT);
trainSize = config.getInt(TRAINSIZE_OPT);
iters = config.getInt(ITER_OPT);
modelSize = config.getInt(MODEL_SIZE_OPT);
repeats = config.getInt(REPEAT_OPT);
rightMerge = config.getBoolean(RIGHT_MERGE_STRATEGY);
implicitComplete = config.getBoolean(IMPLICIT_COMPLETE_STRATEGY);
constrainedMerge = config.getBoolean(CONSTRAINED_MERGE_STRATEGY);
fixedMweOnly = config.getBoolean(FIXED_MWE_ONLY);
noSyntax = config.getBoolean(NO_SYNTACTIC_ANALYSIS);
baseline = config.getBoolean(BASELINE);
projective = config.getBoolean(PROJECTIVE_OPT);
xconll = config.getBoolean(XCONLL_INPUT);
if(!rightMerge && constrainedMerge){
throw new IllegalStateException("The constrained merge strategy can only be applied with a right merge strategy!!");
}
if(iters <= 0){
throw new IllegalStateException("number of training iterations should be positive");
}
if(modelSize <= 0){
throw new IllegalStateException("number of feature identifiers should be positive");
}
if(repeats <= 0){
throw new IllegalStateException("number of repeats should be positive");
}
}
示例10: main
import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
public static void main( String arg[] ) throws IOException, JSAPException {
SimpleJSAP jsap = new SimpleJSAP( ErdosRenyiGraph.class.getName(), "Generates an Erd\u0151s-R\u00E9nyi random graph and stores it as a BVGraph.",
new Parameter[] {
new Switch( "loops", 'l', "loops", "Whether the graph should include self-loops." ),
new FlaggedOption( "p", JSAP.DOUBLE_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'p', "The probability of generating an arc." ),
new FlaggedOption( "m", JSAP.LONGSIZE_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'm', "The expected number of arcs." ),
new UnflaggedOption( "basename", JSAP.STRING_PARSER, JSAP.REQUIRED, "The basename of the output graph file." ),
new UnflaggedOption( "n", JSAP.INTEGER_PARSER, JSAP.REQUIRED, "The number of nodes." ),
});
JSAPResult jsapResult = jsap.parse( arg );
if ( jsap.messagePrinted() ) System.exit( 1 );
final String baseName = jsapResult.getString( "basename" );
final int n = jsapResult.getInt( "n" );
final boolean loops = jsapResult.getBoolean( "loops" );
if ( jsapResult.userSpecified( "p" ) && jsapResult.userSpecified( "m" ) ) {
System.err.println( "Options p and m cannot be specified together" );
System.exit( 1 );
}
if ( ! jsapResult.userSpecified( "p" ) && ! jsapResult.userSpecified( "m" ) ) {
System.err.println( "Exactly one of the options p and m must be specified" );
System.exit( 1 );
}
BVGraph.store( ( jsapResult.userSpecified( "p" ) ? new ErdosRenyiGraph( n, jsapResult.getDouble( "p" ), loops ) : new ErdosRenyiGraph( n, jsapResult.getLong( "m" ), loops ) ), baseName, new ProgressLogger() );
}
示例11: main
import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
public static void main( String arg[] ) throws IOException, JSAPException {
SimpleJSAP jsap = new SimpleJSAP( ConnectedComponents.class.getName(),
"Computes the connected components of a symmetric graph of given basename. The resulting data is saved " +
"in files stemmed from the given basename with extension .wcc (a list of binary integers specifying the " +
"component of each node) and .wccsizes (a list of binary integer specifying the size of each component). " +
"The symmetric graph can also be specified using a generic (non-symmetric) graph and its transpose.",
new Parameter[] {
new Switch( "sizes", 's', "sizes", "Compute component sizes." ),
new Switch( "renumber", 'r', "renumber", "Renumber components in decreasing-size order." ),
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( "mapped", 'm', "mapped", "Do not load the graph in main memory, but rather memory-map it." ),
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." ),
new FlaggedOption( "basenamet", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 't', "transpose", "The basename of the transpose, in case the graph is not symmetric." ),
new UnflaggedOption( "basename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The basename of a symmetric graph (or of a generic graph, if the transpose is provided, too)." ),
new UnflaggedOption( "resultsBasename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, JSAP.NOT_GREEDY, "The basename of the resulting files." ),
}
);
JSAPResult jsapResult = jsap.parse( arg );
if ( jsap.messagePrinted() ) System.exit( 1 );
final String basename = jsapResult.getString( "basename" );
final String basenamet = jsapResult.getString( "basenamet" );
final String resultsBasename = jsapResult.getString( "resultsBasename", basename );
final int threads = jsapResult.getInt( "threads" );
ProgressLogger pl = new ProgressLogger( LOGGER, jsapResult.getLong( "logInterval" ), TimeUnit.MILLISECONDS );
ImmutableGraph graph = jsapResult.userSpecified( "mapped" ) ? ImmutableGraph.loadMapped( basename ) : ImmutableGraph.load( basename, pl );
ImmutableGraph grapht = basenamet == null ? null : jsapResult.userSpecified( "mapped" ) ? ImmutableGraph.loadMapped( basenamet ) : ImmutableGraph.load( basenamet, pl );
final ConnectedComponents components = ConnectedComponents.compute( basenamet != null ? new UnionImmutableGraph( graph, grapht ) : graph, threads, pl );
if ( jsapResult.getBoolean( "sizes" ) || jsapResult.getBoolean( "renumber" ) ) {
final int size[] = components.computeSizes();
if ( jsapResult.getBoolean( "renumber" ) ) components.sortBySize( size );
if ( jsapResult.getBoolean( "sizes" ) ) BinIO.storeInts( size, resultsBasename + ".wccsizes" );
}
BinIO.storeInts( components.component, resultsBasename + ".wcc" );
}
示例12: main
import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
public static void main( String arg[] ) throws IOException, JSAPException {
SimpleJSAP jsap = new SimpleJSAP( StronglyConnectedComponents.class.getName(),
"Computes the strongly connected components (and optionally the buckets) of a graph of given basename. The resulting data is saved " +
"in files stemmed from the given basename with extension .scc (a list of binary integers specifying the " +
"component of each node), .sccsizes (a list of binary integer specifying the size of each component) and .buckets " +
" (a serialised LongArrayBigVector specifying buckets). Please use suitable JVM options to set a large stack size.",
new Parameter[] {
new Switch( "sizes", 's', "sizes", "Compute component sizes." ),
new Switch( "renumber", 'r', "renumber", "Renumber components in decreasing-size order." ),
new Switch( "buckets", 'b', "buckets", "Compute buckets (nodes belonging to a bucket component, i.e., a terminal nondangling component)." ),
new FlaggedOption( "filter", new ObjectParser( LabelledArcFilter.class, GraphClassParser.PACKAGE ), JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'f', "filter", "A filter for labelled arcs; requires the provided graph to be arc labelled." ),
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 UnflaggedOption( "basename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The basename of the graph." ),
new UnflaggedOption( "resultsBasename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, JSAP.NOT_GREEDY, "The basename of the resulting files." ),
}
);
JSAPResult jsapResult = jsap.parse( arg );
if ( jsap.messagePrinted() ) System.exit( 1 );
final String basename = jsapResult.getString( "basename" );
final String resultsBasename = jsapResult.getString( "resultsBasename", basename );
final LabelledArcFilter filter = (LabelledArcFilter)jsapResult.getObject( "filter" );
ProgressLogger pl = new ProgressLogger( LOGGER, jsapResult.getLong( "logInterval" ), TimeUnit.MILLISECONDS );
final StronglyConnectedComponents components =
filter != null ? StronglyConnectedComponents.compute( ArcLabelledImmutableGraph.load( basename ), filter, jsapResult.getBoolean( "buckets" ), pl )
: StronglyConnectedComponents.compute( ImmutableGraph.load( basename ), jsapResult.getBoolean( "buckets" ), pl );
if ( jsapResult.getBoolean( "sizes" ) || jsapResult.getBoolean( "renumber" ) ) {
final int size[] = components.computeSizes();
if ( jsapResult.getBoolean( "renumber" ) ) components.sortBySize( size );
if ( jsapResult.getBoolean( "sizes" ) ) BinIO.storeInts( size, resultsBasename + ".sccsizes" );
}
BinIO.storeInts( components.component, resultsBasename + ".scc" );
if ( components.buckets != null ) BinIO.storeObject( components.buckets, resultsBasename + ".buckets" );
}
示例13: main
import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
public static void main( final String[] arg ) throws IOException, InterruptedException, JSAPException {
SimpleJSAP jsap = new SimpleJSAP( BetweennessCentrality.class.getName(), "Computes the betweenness centrality a graph using an implementation of Brandes's algorithm based on multiple parallel breadth-first visits.",
new Parameter[] {
new Switch( "expand", 'e', "expand", "Expand the graph to increase speed (no compression)." ),
new Switch( "mapped", 'm', "mapped", "Use loadMapped() to load the graph." ),
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." ),
new UnflaggedOption( "graphBasename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The basename of the graph." ),
new UnflaggedOption( "rankFilename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The filename where the resulting rank (doubles in binary form) are stored." )
}
);
JSAPResult jsapResult = jsap.parse( arg );
if ( jsap.messagePrinted() ) System.exit( 1 );
final boolean mapped = jsapResult.getBoolean( "mapped", false );
final String graphBasename = jsapResult.getString( "graphBasename" );
final String rankFilename = jsapResult.getString( "rankFilename" );
final int threads = jsapResult.getInt( "threads" );
final ProgressLogger progressLogger = new ProgressLogger( LOGGER, "nodes" );
progressLogger.displayFreeMemory = true;
progressLogger.displayLocalSpeed = true;
ImmutableGraph graph = mapped? ImmutableGraph.loadMapped( graphBasename, progressLogger ) : ImmutableGraph.load( graphBasename, progressLogger );
if ( jsapResult.userSpecified( "expand" ) ) graph = new ArrayListMutableGraph( graph ).immutableView();
BetweennessCentrality betweennessCentralityMultipleVisits = new BetweennessCentrality( graph, threads, progressLogger );
betweennessCentralityMultipleVisits.compute();
BinIO.storeDoubles( betweennessCentralityMultipleVisits.betweenness, rankFilename );
}
示例14: main
import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
public static void main( final String[] arg ) throws IOException, JSAPException, InterruptedException {
SimpleJSAP jsap = new SimpleJSAP( GeometricCentralities.class.getName(), "Computes centralities of a graph using multiple parallel breadth-first visits.",
new Parameter[] {
new Switch( "expand", 'e', "expand", "Expand the graph to increase speed (no compression)." ),
new Switch( "mapped", 'm', "mapped", "Use loadMapped() to load the graph." ),
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." ),
new UnflaggedOption( "graphBasename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The basename of the graph." ),
new UnflaggedOption( "closenessFilename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The filename where closeness-centrality scores (doubles in binary form) will be stored." ),
new UnflaggedOption( "linFilename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The filename where Lin's-centrality scores (doubles in binary form) will be stored." ),
new UnflaggedOption( "harmonicFilename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The filename where harmonic-centrality scores (doubles in binary form) will be stored." ),
new UnflaggedOption( "reachableFilename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The filename where the number of reachable nodes (longs in binary form) will be stored." )
}
);
JSAPResult jsapResult = jsap.parse( arg );
if ( jsap.messagePrinted() ) System.exit( 1 );
final boolean mapped = jsapResult.getBoolean( "mapped", false );
final String graphBasename = jsapResult.getString( "graphBasename" );
final int threads = jsapResult.getInt( "threads" );
final ProgressLogger progressLogger = new ProgressLogger( LOGGER, "nodes" );
progressLogger.displayFreeMemory = true;
progressLogger.displayLocalSpeed = true;
ImmutableGraph graph = mapped? ImmutableGraph.loadMapped( graphBasename, progressLogger ) : ImmutableGraph.load( graphBasename, progressLogger );
if ( jsapResult.userSpecified( "expand" ) ) graph = new ArrayListMutableGraph( graph ).immutableView();
GeometricCentralities centralities = new GeometricCentralities( graph, threads, progressLogger );
centralities.compute();
BinIO.storeDoubles( centralities.closeness, jsapResult.getString( "closenessFilename" ) );
BinIO.storeDoubles( centralities.lin, jsapResult.getString( "linFilename" ) );
BinIO.storeDoubles( centralities.harmonic, jsapResult.getString( "harmonicFilename" ) );
BinIO.storeLongs( centralities.reachable, jsapResult.getString( "reachableFilename" ) );
}
示例15: main
import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
public static void main( String args[] ) throws IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, IOException, JSAPException, ClassNotFoundException, InstantiationException {
String sourceBasename, destBasename;
Class<?> graphClass;
SimpleJSAP jsap = new SimpleJSAP( ASCIIGraph.class.getName(), "Reads a graph with a given basename, or a given spec, and writes it out in ASCII format with another basename",
new Parameter[] {
new FlaggedOption( "graphClass", GraphClassParser.getParser(), null, JSAP.NOT_REQUIRED, 'g', "graph-class", "Forces a Java class for the source graph" ),
new FlaggedOption( "shift", JSAP.INTEGER_PARSER, null, JSAP.NOT_REQUIRED, 'S', "shift", "A shift that will be added to each node index." ),
new Switch( "spec", 's', "spec", "The source is not a basename but rather a spec of the form ImmutableGraphClass(arg,arg,...)." ),
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 UnflaggedOption( "sourceBasename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The basename of the source graph, or a source spec if --spec was given; it is immaterial when --once is specified." ),
new UnflaggedOption( "destBasename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The basename of the destination graph" ),
}
);
JSAPResult jsapResult = jsap.parse( args );
if ( jsap.messagePrinted() ) System.exit( 1 );
graphClass = jsapResult.getClass( "graphClass" );
sourceBasename = jsapResult.getString( "sourceBasename" );
destBasename = jsapResult.getString( "destBasename" );
final boolean spec = jsapResult.getBoolean( "spec" );
final ProgressLogger pl = new ProgressLogger( LOGGER, jsapResult.getLong( "logInterval" ), TimeUnit.MILLISECONDS );
if ( graphClass != null && spec ) {
System.err.println( "Options --graphClass and --spec are incompatible" );
return;
}
ImmutableGraph graph;
if ( !spec )
graph = graphClass != null
? (ImmutableGraph)graphClass.getMethod( "loadSequential", CharSequence.class, ProgressLogger.class ).invoke( null, sourceBasename, pl )
: ImmutableGraph.loadSequential( sourceBasename, pl );
else
graph = ObjectParser.fromSpec( sourceBasename, ImmutableGraph.class, GraphClassParser.PACKAGE );
if ( jsapResult.userSpecified( "shift" ) ) ASCIIGraph.store( graph, jsapResult.getInt( "shift" ), destBasename );
else ASCIIGraph.store( graph, destBasename );
}