* Generate a graph object for the logical plan.
*
* @return the graph object
*/
protected Graph generateGraph() {
Graph gv = new Graph();
Map<String, Graph> subgraphs = Maps.newHashMap();
gv.attr("rankdir", "TB");
Map<P2jLogicalRelationalOperator, Node> graphMap = Maps.newHashMap();
for (Entry<String, P2jLogicalRelationalOperator> e : p2jMap.entrySet()) {
Node node = new Node();
graphMap.put(e.getValue(), node);
}
for (Entry<P2jLogicalRelationalOperator, Node> e : graphMap.entrySet()) {
Node node = e.getValue();
attributeGraphNode(node, e.getKey());
if (!appendToSubgraph(subgraphs, node, e.getKey())) {
gv.node(node);
}
for (String i : e.getKey().getSuccessors()) {
P2jLogicalRelationalOperator dst = p2jMap.get(i);
Edge edge = new Edge(node, graphMap.get(dst));
gv.edge(edge);
}
}
for (Entry<String, Graph> sg : subgraphs.entrySet()) {
gv.subGraph(sg.getValue());
}
return gv;
}