From: H.N. de R. <hnr...@gr...> - 2012-06-21 19:21:14
|
On Wed, Jun 20, 2012 at 08:37:43AM -0700, rima asmar wrote: Hello Rima, > Can u plz give me a simple example of how i can use the > ComponentAttributeProvider !! I could do the exporting to .dot, but with no > attributes at all, so do i add the attributes to the .dot file? Check the test code for DOTExporter: public void testUndirected() { UndirectedGraph<String, DefaultEdge> g = new SimpleGraph<String, DefaultEdge>(DefaultEdge.class); g.addVertex(V1); g.addVertex(V2); g.addEdge(V1, V2); g.addVertex(V3); g.addEdge(V3, V1); StringWriter w = new StringWriter(); ComponentAttributeProvider<String> vertexAttributeProvider = new ComponentAttributeProvider<String>() { public Map<String, String> getComponentAttributes(String v) { Map<String, String> map = new LinkedHashMap<String, String>(); if (v.equals(V1)) { map.put("label", "a"); } else if (v.equals(V2)) { map.put("x", "y"); } else { map = null; } return map; } }; DOTExporter<String, DefaultEdge> exporter = new DOTExporter<String, DefaultEdge>( new IntegerNameProvider<String>(), null, null, vertexAttributeProvider, null); exporter.export(w, g); } In your case you would want something like map.put("shape", "polygon") instead of map.put("label", "a"). Regards, Ernst -- Information System on Graph Classes and their Inclusions (ISGCI) http://www.graphclasses.org |