I am building a project on graph theory algorithms and for this I use JGraphT. I have built completely my graph and I work on it the past couple of months. Now I want to export it so I can visualize it in Gephi. I don't want to use JGraph and Java visualization since I already have enough of code and I want to keep it simple. I want to use DOTExporter class from JgraphT. I have reached to a point were I export fine vertices and edges, but not edges weights.
So this is my export function. I don't know how to implement ComponentAttributeProvider
interface and cannot find my way out of this mess.
Any ideas what I should put instead of null, null?
static public void exportGraph(){
StringNameProvider<CustomVertex> p1=new StringNameProvider<CustomVertex>();
IntegerNameProvider<CustomVertex> p2=new IntegerNameProvider<CustomVertex>();
StringEdgeNameProvider<CustomWeightedEdge> p3 = new StringEdgeNameProvider<CustomWeightedEdge>();
DOTExporter export=new DOTExporter(p2, p1, p3, null, null);
try {
export.export(new FileWriter("graph.dot"), g);
}catch (IOException e){}
}
I have done something like this
ComponentAttributeProvider<CustomWeightedEdge> edgeAttributeProvider =
new ComponentAttributeProvider<CustomWeightedEdge>() {
public Map<String, String> getComponentAttributes(CustomWeightedEdge e) {
Map<String, String> map =new LinkedHashMap<String, String>();
map.put("weight", Double.toString(g.getEdgeWeight(e)));
return map;
}
};