How do i use GraphMLReader2 in Jung?
- by askus
I want to use class GraphMLReader to read a Undirected Graph from graphML with JUNG2.0.
The code is as follow:
import edu.uci.ics.jung.io.*;
import edu.uci.ics.jung.io.graphml.*;
import java.io.*;
import java.util.*;
import org.apache.commons.collections15.Transformer;
import edu.uci.ics.jung.graph.*;
class Vertex{
int id;
String type;
String value;
}
class Edge{
int id ;
String type;
String value;
}
public class Loader{
static String src = "test.xsl";
public static void Main( String[] args){
Reader reader = new FileReader(src );
Transformer<NodeMetadata, Vertex> vtrans = new Transformer<NodeMetadata,Vertex>(){
public Vertex transform(NodeMetadata nmd ){
Vertex v = new Vertex() ;
v.type = nmd.getProperty("type");
v.value = nmd.getProperty("value");
v.id = Integer.valueOf( nmd.getId() );
return v;
}
};
Transformer<EdgeMetadata, Edge> etrans = new Transformer<EdgeMetadata,Edge>(){
public Edge transform( EdgeMetadata emd ){
Edge e = new Edge() ;
e.type = emd.getProperty("type");
e.value = emd.getProperty("value");
e.id = Integer.valueOf( emd.getId() );
return e;
}
};
Transformer<HyperEdgeMetadata, Edge> hetrans = new Transformer<HyperEdgeMetadata,Edge>(){
public Edge transform( HyperEdgeMetadata emd ){
Edge e = new Edge() ;
e.type = emd.getProperty("type");
e.value = emd.getProperty("value");
e.id = Integer.valueOf( emd.getId() );
return e;
}
};
Transformer< GraphMetadata , UndirectedSparseGraph> gtrans = new Transformer<GraphMetadata,UndirectedSparseGraph>(){
public UndirectedSparseGraph<Vertex,Edge> transform( GraphMetadata gmd ){
return new UndirectedSparseGraph<Vertex,Edge>();
}
};
GraphMLReader2< UndirectedSparseGraph<Vertex,Edge> , Vertex , Edge> gmlr =
new GraphMLReader2< UndirectedSparseGraph<Vertex,Edge> ,Vertex, Edge>(
reader,
gtrans,
vtrans,
etrans,
hetrans);
UndirectedSparseGraph<Vertex,Edge> g = gmlr.readGraph();
return ;
}
}
However, compiler alert that:
Loader.java:60: cannot find symbol
symbol : constructor GraphMLReader2(java.io.Reader,org.apache.commons.collections15.Transformer<edu.uci.ics.jung.io.graphml.GraphMetadata,edu.uci.ics.jung.graph.UndirectedSparseGraph>,org.apache.commons.collections15.Transformer<edu.uci.ics.jung.io.graphml.NodeMetadata,Vertex>,org.apache.commons.collections15.Transformer<edu.uci.ics.jung.io.graphml.EdgeMetadata,Edge>)
location: class edu.uci.ics.jung.io.graphml.GraphMLReader2<edu.uci.ics.jung.graph.UndirectedSparseGraph<Vertex,Edge>,Vertex,Edge>
new GraphMLReader2< UndirectedSparseGraph<Vertex,Edge> ,Vertex, Edge>(
^
1 error
How can i solve this problem? Thanks.