本文整理匯總了Java中edu.uci.ics.jung.io.PajekNetWriter類的典型用法代碼示例。如果您正苦於以下問題:Java PajekNetWriter類的具體用法?Java PajekNetWriter怎麽用?Java PajekNetWriter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
PajekNetWriter類屬於edu.uci.ics.jung.io包,在下文中一共展示了PajekNetWriter類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import edu.uci.ics.jung.io.PajekNetWriter; //導入依賴的package包/類
public static void main( final String[] arg ) throws IOException, JSAPException {
final SimpleJSAP simpleJSAP = new SimpleJSAP( JungAdapter.class.getName(), "Reads a graph with a given basename, optionally its transpose, and writes it on standard output in Pajek format.",
new Parameter[] {
new Switch( "offline", 'o', "offline", "Use the offline load method to reduce memory consumption. It usually works, but your mileage may vary." ),
new UnflaggedOption( "basename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The basename of the source graph." ),
new UnflaggedOption( "transpose", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, JSAP.NOT_GREEDY, "The basename of the transpose. If unspecified, the JungAdapter constructor will be provided with null as a parameter. This usually works, but your mileage may vary." )
});
final JSAPResult jsapResult = simpleJSAP.parse( arg );
if ( simpleJSAP.messagePrinted() ) System.exit( 1 );
final boolean offline = jsapResult.userSpecified( "offline" );
final ImmutableGraph graph = offline ? ImmutableGraph.loadOffline( jsapResult.getString( "basename" ) ) : ImmutableGraph.load( jsapResult.getString( "basename" ) );
final ImmutableGraph transpose = jsapResult.userSpecified( "transpose" ) ? ( offline ? ImmutableGraph.loadOffline( jsapResult.getString( "transpose" ) ) : ImmutableGraph.load( jsapResult.getString( "transpose" ) ) ) : null;
final PrintWriter printWriter = new PrintWriter( System.out );
new PajekNetWriter<Integer, Long>().save( new JungAdapter( graph, transpose ), printWriter );
printWriter.flush();
}
示例2: exportPajek
import edu.uci.ics.jung.io.PajekNetWriter; //導入依賴的package包/類
private void exportPajek() {
try {
//int res = fileChooser.showSaveDialog(this);
int res = fileChooser.showSaveDialog(getOwner());
if (res == JFileChooser.APPROVE_OPTION) {
File f = fileChooser.getSelectedFile();
Transformer<V, String> vertexTransformer = new Transformer<V, String>() {
public String transform(V vertex) {
return vertex.toString();
}
};
Transformer<E, Number> edgeTransformer = new Transformer<E, Number>() {
public Number transform(E arg0) {
return 1;
}
};
String path = f.getAbsolutePath();
if (!path.endsWith(".net")) {
path += ".net";
}
PajekNetWriter<V, E> writer = new PajekNetWriter<V, E>();
writer.save(networkPanel.getGraph(), path, vertexTransformer,
edgeTransformer);
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
示例3: exportGraph
import edu.uci.ics.jung.io.PajekNetWriter; //導入依賴的package包/類
public void exportGraph() {
PajekNetWriter<Agent, WeightedEdge> graphWriter =
new PajekNetWriter<Agent, WeightedEdge>();
// DotWriter<Agent, WeightedEdge> graphWriter =
// new DotWriter<Agent, WeightedEdge>();
try {
String fileName = baseFileName + "-" + this.graphNumber + ".net";
PrintWriter out = new PrintWriter(fileName);
Transformer<WeightedEdge, Number> nev =
new Transformer<WeightedEdge, Number>() {
public Number transform(WeightedEdge str) {
return new Double(str.getValue());
}
};
Transformer<Agent, String> vs =
new Transformer<Agent, String>() {
public String transform(Agent agent) {
// AbstractTradingAgent tradingAgent = (AbstractTradingAgent) agent;
// double score = tradingAgent.getFunds();
// return "" + imageScoreAgent.hashCode() + ":" + score;
// return new DecimalFormat("#.00").format(score);
return agent.getClass().toString();
}
};
graphWriter.save(tradeNetworkReport.getGraph(), out, vs, nev);
this.graphNumber++;
} catch (IOException e) {
throw new RuntimeException(e);
}
}