Package org.kohsuke.graphviz

Examples of org.kohsuke.graphviz.Graph


    protected Boolean appendToSubgraph(Map<String, Graph> subgraphs, Node node, P2jLogicalRelationalOperator oper) {
        String jid = null;
        if (oper.getMapReduce() != null && oper.getMapReduce().getJobId() != null) {
            jid = oper.getMapReduce().getJobId();
            if (!subgraphs.containsKey(jid)) {
                Graph g = new Graph();
                g.id("cluster_" + jid.replaceAll("-", ""));
                g.attr("bgcolor", BG_CLUSTER);
                Style s = new Style();
                s.attr("rounded");
                s.attr("filled");
                g.style(s);
                subgraphs.put(jid, g);
            }
            subgraphs.get(jid).node(node);
            return false;
        }
View Full Code Here


     * 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;
    }
View Full Code Here

        LOG.info("Generating script graphic of type " + format);
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        List<String> args = Lists.newArrayList();
        args.add("dot");
        args.add("-T" + format);
        Graph g = generateGraph();
        g.generateTo(args, os);
        return os.toString();
    }
View Full Code Here

TOP

Related Classes of org.kohsuke.graphviz.Graph

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.