2
그래프 이론 알고리즘에 대한 프로젝트를 작성 중이며 이에 대해 JGraphT을 사용합니다. 나는 내 그래프를 완전히 만들었고 나는 지난 몇 달 동안 그것을 작업했다. 이제 그것을 내보냄으로써 Gephi에서 시각화 할 수 있습니다. 이미 충분한 코드를 가지고 있으므로 JGraph 및 Java 시각화를 사용하고 싶지 않고 간단하게 유지하려고합니다. DOTExporter class from JgraphT을 사용하고 싶습니다. 내가 좋은 정점과 가장자리를 내보냈지만 가장자리 가중치가 아닌 것이 었습니다.JgraphT 도트 파일로 내 보냅니다.
내 내보내기 기능입니다. 나는 ComponentAttributeProvider
인터페이스를 구현하는 방법을 모르며이 혼란에서 벗어날 수는 없습니다.
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){}
}
것은 내가이
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;
}
};