本文整理汇总了Java中edu.uci.ics.jung.io.PajekNetReader.load方法的典型用法代码示例。如果您正苦于以下问题:Java PajekNetReader.load方法的具体用法?Java PajekNetReader.load怎么用?Java PajekNetReader.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.uci.ics.jung.io.PajekNetReader
的用法示例。
在下文中一共展示了PajekNetReader.load方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: load
import edu.uci.ics.jung.io.PajekNetReader; //导入方法依赖的package包/类
public void load(File netFile){
VertexFactory vertexFactory = new VertexFactory();
EdgeFactory edgeFactory = new EdgeFactory();
PajekNetReader<PajekNetwork, Vertex, Edge> pReader = new PajekNetReader<PajekNetwork, Vertex, Edge>(vertexFactory, edgeFactory);
try {
pReader.load(netFile.getAbsolutePath(), this);
} catch (IOException ioEx) {
JOptionPane.showMessageDialog(null,ioEx.getMessage(),"Error",JOptionPane.ERROR_MESSAGE);
System.err.println("Input error in Pajek file");
ioEx.printStackTrace();
}
for (Vertex v : getVertices())
v.setLabel(pReader.getVertexLabeller().transform(v));
if (pReader.getEdgeWeightTransformer() != null)
for (Edge e : getEdges())
if (pReader.getEdgeWeightTransformer().transform(e) != null)
e.setWeight(pReader.getEdgeWeightTransformer().transform(e).doubleValue());
}
示例2: main
import edu.uci.ics.jung.io.PajekNetReader; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException, UniqueLabelException {
JFrame jf = new JFrame("Scott's Toy Network Viewer");
// PajekNetFile file = new PajekNetFile();
// file.setCreateDirectedOnly(true);
// Graph g = file.load("samples/datasets/smyth.net");
PajekNetReader pnr = new PajekNetReader(true);
Graph ug = pnr.load("samples/datasets/smyth.net", new SparseGraph());
Graph g = DirectionTransformer.toDirected(ug);
GraphUtils.copyLabels(StringLabeller.getLabeller(ug, PajekNetReader.LABEL),
StringLabeller.getLabeller(g, PajekNetReader.LABEL));
RankingDemo vizApp = new RankingDemo(g);
jf.getContentPane().add(vizApp);
jf.setSize(700, 500);
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jf.pack();
jf.setVisible(true);
}
示例3: start
import edu.uci.ics.jung.io.PajekNetReader; //导入方法依赖的package包/类
public void start() {
System.out.println("Starting in applet mode.");
InputStream is =
this.getClass().getClassLoader().getResourceAsStream(
"samples/datasets/smyth.net");
BufferedReader br = new BufferedReader(new InputStreamReader(is));
PajekNetReader pnr = new PajekNetReader(true);
try
{
Graph ug = pnr.load(br, new SparseGraph());
Graph g = DirectionTransformer.toDirected(ug);
GraphUtils.copyLabels(StringLabeller.getLabeller(ug, PajekNetReader.LABEL),
StringLabeller.getLabeller(g, PajekNetReader.LABEL));
// Graph g = pnr.load(br, new UndirectedSparseGraph());
RankingDemo vizApp = new RankingDemo(g);
getContentPane().add(vizApp);
}
catch (IOException e)
{
System.out.println("Error in loading graph");
e.printStackTrace();
}
catch (UniqueLabelException ule)
{
System.out.println("Unexpected duplicate label");
ule.printStackTrace();
}
}
示例4: getGraph
import edu.uci.ics.jung.io.PajekNetReader; //导入方法依赖的package包/类
/**
* Generates a graph: in this case, reads it from the file
* "samples/datasetsgraph/simple.net"
* @return A sample undirected graph
*/
public static Graph getGraph() throws IOException
{
PajekNetReader pnr = new PajekNetReader(FactoryUtils.instantiateFactory(Object.class));
Graph g = new UndirectedSparseGraph();
pnr.load("src/main/resources/datasets/simple.net", g);
return g;
}
示例5: loadGraph
import edu.uci.ics.jung.io.PajekNetReader; //导入方法依赖的package包/类
private void loadGraph()
{
// Our graph
sequenceGraph = new UndirectedSparseGraph<Vertex, Edge>();
// Will Create and load the vertex/edge created with the factory
PajekNetReader<Graph<Vertex, Edge>, Vertex, Edge> fileReader = new PajekNetReader<Graph<Vertex, Edge>, Vertex, Edge>(Vertex.getFactory(), Edge.getFactory());
fileReader.setVertexLabeller(new MapSettableTransformer<Vertex, String>(new HashMap<Vertex, String>()));
fileReader.setEdgeWeightTransformer(new MapSettableTransformer<Edge, Number>(new HashMap<Edge, Number>()));
try {
fileReader.load("/home/etienne/__A__/Dev/Reidentification/Data/OutputReid/network.net", sequenceGraph);
} catch (IOException e) {
System.err.println("Cannot load the network file");
e.printStackTrace();
}
for (Vertex node : sequenceGraph.getVertices())
{
node.setLabel(fileReader.getVertexLabeller().transform(node));
}
for (Edge edge : sequenceGraph.getEdges())
{
edge.setWeight(fileReader.getEdgeWeightTransformer().transform(edge).floatValue());
}
}
示例6: getGraph
import edu.uci.ics.jung.io.PajekNetReader; //导入方法依赖的package包/类
public static Graph getGraph(String FileName) throws IOException
{
PajekNetReader pnr = new PajekNetReader(FactoryUtils.instantiateFactory(Object.class));
Graph g = new UndirectedSparseGraph();
pnr.load(FileName, g);
return g;
}
示例7: getGraph
import edu.uci.ics.jung.io.PajekNetReader; //导入方法依赖的package包/类
/**
* Generates a graph: in this case, reads it from the file
* "samples/datasetsgraph/simple.net"
* @return A sample undirected graph
*/
public static Graph getGraph() throws IOException {
PajekNetReader pnr = new PajekNetReader();
Graph g = pnr.load("samples/datasets/simple.net");
return g;
}