Package edu.uci.ics.jung.graph

Examples of edu.uci.ics.jung.graph.DirectedSparseMultigraph


            }
           
            primitives.graph.Graph g = new primitives.graph.Graph(ch.getNodes());


            DirectedSparseMultigraph go = new DirectedSparseMultigraph();
            //HashMap<Node,String> nodes = new HashMap<Node,String>();
            for (Node n : g.getNodes()) {
                go.addVertex(n);

            }

            for (Node n : g.getNodes()) {
                for (Transition t : n.getTransitionsAsT()) {
                    go.addEdge(t.getLabel() + "<!--" +  Math.random() + "-->", n, t.getDestinationNode());
                    //JUNG's E set must be distinct, so chuck some random crap on the end of each label
                    //to make each one unique.  HTML is used when rendering so we hide the random crap with a comment
                }
            }
            try {
                if(!model.isClusterHead())
                    ch = SILReader.clusterTreeBySIL(g, new File(model.getSilName()));
               
                HashMap<String, HashSet<Node>> clusters = new HashMap<String, HashSet<Node>>();

                for (IClusterLevel l : ch.getChildren()) {
                    String c = "C" + Math.random();
                    clusters.put(c, new HashSet<Node>());
                    for (Node n : l.getNodes()) {
                        clusters.get(c).add(n);
                    }

                }
                //Logger.getLogger(ClusterViewerController.class.getName()).log(Level.INFO, String.format("KeySet size is %d",clusters.keySet().size()));
                Set<Set<Node>> ass = new HashSet<Set<Node>>();
                for (String key : clusters.keySet()) {
                    ass.add(clusters.get(key));
                }

                //Logger.getLogger(ClusterViewerController.class.getName()).log(Level.WARNING, String.format("Assignments has %d clusters",ass.size()));
                model.setClusterAssignments(ass);
            } catch (FileNotFoundException fne) {
                model.setStatus("SIL file not found.  Unclustered graph will be drawn");
                gui.updateGUI();
                Logger.getLogger(ClusterViewerController.class.getName()).log(Level.WARNING, "404:", fne);
            }

            model.setGraph(go);
            model.setStatus(String.format("Graph loaded.  %d nodes",go.getVertexCount()));
            gui.updateGUI();
            Logger.getLogger(ClusterViewerController.class.getName()).log(Level.INFO, String.format("Sending %s to render", model.getDotName()));
            //gui.drawGraph();
        } catch (Exception e) {
            Logger.getLogger(ClusterViewerController.class.getName()).log(Level.WARNING, "ffffuuuuuu", e);
View Full Code Here

TOP

Related Classes of edu.uci.ics.jung.graph.DirectedSparseMultigraph

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.