use of org.candle.decompiler.instruction.graph.vertex.NamedDirectedSubgraph in project candle-decompiler by bradsdavis.
the class DOTSubgraphExporter method export.
//~ Methods ----------------------------------------------------------------
/**
* Exports a graph into a plain text file in DOT format.
*
* @param writer the writer to which the graph to be exported
* @param g the graph to be exported
*/
public void export(Writer writer, Subgraph<V, E, ?> g) {
String name = UUID.randomUUID().toString();
if (g instanceof NamedDirectedSubgraph) {
name = ((NamedDirectedSubgraph) g).getName();
}
PrintWriter out = new PrintWriter(writer);
String indent = " ";
String connector;
if (g instanceof DirectedGraph<?, ?>) {
out.println("subgraph cluster_" + name + " {");
connector = " -> ";
} else {
out.println("subgraph cluster_" + name + " {");
connector = " -- ";
}
for (V v : g.vertexSet()) {
out.print(indent + getVertexID(v));
String labelName = null;
if (vertexLabelProvider != null) {
labelName = vertexLabelProvider.getVertexName(v);
}
Map<String, String> attributes = null;
if (vertexAttributeProvider != null) {
attributes = vertexAttributeProvider.getComponentAttributes(v);
}
renderAttributes(out, labelName, attributes);
out.println(";");
}
out.println("label=\"" + name + "\";");
out.println("}");
out.flush();
}
Aggregations