Package edu.uci.ics.jung.graph

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


{

    public static void main(String[] args) throws IOException
    {
        JFrame jf = new JFrame();
        Graph g = getGraph();
        VisualizationViewer vv = new VisualizationViewer(new FRLayout(g));
        jf.getContentPane().add(vv);
        jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        jf.pack();
        jf.setVisible(true);
View Full Code Here


     * @return A sample undirected graph
     */
    public static Graph getGraph() throws IOException
    {
        PajekNetReader pnr = new PajekNetReader(FactoryUtils.instantiateFactory(Object.class));
        Graph g = new UndirectedSparseGraph();
       
        pnr.load("src/main/resources/datasets/simple.net", g);
        return g;
    }
View Full Code Here

        collapse.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                Collection picked = new HashSet(vv.getPickedVertexState().getPicked());
                if(picked.size() > 1) {
                    Graph inGraph = layout.getGraph();
                    Graph clusterGraph = collapser.getClusterGraph(inGraph, picked);

                    Graph g = collapser.collapse(layout.getGraph(), clusterGraph);
                    collapsedGraph = g;
                    double sumx = 0;
                    double sumy = 0;
                    for(Object v : picked) {
                      Point2D p = (Point2D)layout.transform(v);
                      sumx += p.getX();
                      sumy += p.getY();
                    }
                    Point2D cp = new Point2D.Double(sumx/picked.size(), sumy/picked.size());
                    vv.getRenderContext().getParallelEdgeIndexFunction().reset();
                    layout.setGraph(g);
                    layout.setLocation(clusterGraph, cp);
                    vv.getPickedVertexState().clear();
                    vv.repaint();
                }
            }});
       
        JButton compressEdges = new JButton("Compress Edges");
        compressEdges.addActionListener(new ActionListener() {

      public void actionPerformed(ActionEvent e) {
        Collection picked = vv.getPickedVertexState().getPicked();
        if(picked.size() == 2) {
          Pair pair = new Pair(picked);
          Graph graph = layout.getGraph();
          Collection edges = new HashSet(graph.getIncidentEdges(pair.getFirst()));
          edges.retainAll(graph.getIncidentEdges(pair.getSecond()));
          exclusions.addAll(edges);
          vv.repaint();
        }
       
      }});
       
        JButton expandEdges = new JButton("Expand Edges");
        expandEdges.addActionListener(new ActionListener() {

      public void actionPerformed(ActionEvent e) {
        Collection picked = vv.getPickedVertexState().getPicked();
        if(picked.size() == 2) {
          Pair pair = new Pair(picked);
          Graph graph = layout.getGraph();
          Collection edges = new HashSet(graph.getIncidentEdges(pair.getFirst()));
          edges.retainAll(graph.getIncidentEdges(pair.getSecond()));
          exclusions.removeAll(edges);
          vv.repaint();
        }
       
      }});
       
        JButton expand = new JButton("Expand");
        expand.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                Collection picked = new HashSet(vv.getPickedVertexState().getPicked());
                for(Object v : picked) {
                    if(v instanceof Graph) {
                       
                        Graph g = collapser.expand(layout.getGraph(), (Graph)v);
                        vv.getRenderContext().getParallelEdgeIndexFunction().reset();
                        layout.setGraph(g);
                    }
                    vv.getPickedVertexState().clear();
                   vv.repaint();
View Full Code Here

        collapse.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                Collection picked = new HashSet(vv.getPickedVertexState().getPicked());
                if(picked.size() > 1) {
                    Graph inGraph = layout.getGraph();
                    Graph clusterGraph = collapser.getClusterGraph(inGraph, picked);

                    Graph g = collapser.collapse(layout.getGraph(), clusterGraph);
                    double sumx = 0;
                    double sumy = 0;
                    for(Object v : picked) {
                      Point2D p = (Point2D)layout.transform(v);
                      sumx += p.getX();
                      sumy += p.getY();
                    }
                    Point2D cp = new Point2D.Double(sumx/picked.size(), sumy/picked.size());
                    vv.getRenderContext().getParallelEdgeIndexFunction().reset();
                    layout.setGraph(g);
                    layout.setLocation(clusterGraph, cp);
                    vv.getPickedVertexState().clear();
                    vv.repaint();
                }
            }});
       
        JButton compressEdges = new JButton("Compress Edges");
        compressEdges.addActionListener(new ActionListener() {

      public void actionPerformed(ActionEvent e) {
        Collection picked = vv.getPickedVertexState().getPicked();
        if(picked.size() == 2) {
          Pair pair = new Pair(picked);
          Graph graph = layout.getGraph();
          Collection edges = new HashSet(graph.getIncidentEdges(pair.getFirst()));
          edges.retainAll(graph.getIncidentEdges(pair.getSecond()));
          exclusions.addAll(edges);
          vv.repaint();
        }
       
      }});
       
        JButton expandEdges = new JButton("Expand Edges");
        expandEdges.addActionListener(new ActionListener() {

      public void actionPerformed(ActionEvent e) {
        Collection picked = vv.getPickedVertexState().getPicked();
        if(picked.size() == 2) {
          Pair pair = new Pair(picked);
          Graph graph = layout.getGraph();
          Collection edges = new HashSet(graph.getIncidentEdges(pair.getFirst()));
          edges.retainAll(graph.getIncidentEdges(pair.getSecond()));
          exclusions.removeAll(edges);
          vv.repaint();
        }
       
      }});
       
        JButton expand = new JButton("Expand");
        expand.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                Collection picked = new HashSet(vv.getPickedVertexState().getPicked());
                for(Object v : picked) {
                    if(v instanceof Graph) {
                       
                        Graph g = collapser.expand(layout.getGraph(), (Graph)v);
                        vv.getRenderContext().getParallelEdgeIndexFunction().reset();
                        layout.setGraph(g);
                    }
                    vv.getPickedVertexState().clear();
                   vv.repaint();
View Full Code Here

    Object2InformationComponent transformer = new Object2InformationComponent();
    Object stringObject = "Christian Test";
   
    List list = Arrays.asList("This", "is", Arrays.asList("christian", "Bauer's"), "list");

    Graph graph = SampleGraphFactory.createSampleGraph1();
   
    TreeNode rootNode = SampleTreeFactory.createSampleTree1();
   
    BoostFunction<String, Boolean,?> leafFilter = new ReflectionFunctions(ReflectionFunctions.Operation.invokeMethod,"equals", "a");
    TreeNode newRootNode = TreeNodeFactory.createLeafFilteringTreeNode(rootNode, FunctionFactory.concatenation(/*<TreeNode, Boolean>*/ new ReflectionFunctions(ReflectionFunctions.Operation.invokeMethod/*<ComputedTreeNode<File>, File>(*/,"getUserObject"), leafFilter), new InvocationContext());
View Full Code Here

 
  public void testCreateStateGraph() throws Exception
  {
     ChainedTransformer transformer = new ChainedTransformer( new Transformer[]{ExceptionTransformer.getInstance(), new ChainedTransformer(new Transformer[]{}), new ConstantTransformer("hallo") });
    
     Graph stateGraph = ModelAnalysisBoostUtils.createStateGraph(transformer);
    
     Window display = JungGraphBoostUtils.displayGraph(stateGraph, JFrame.DISPOSE_ON_CLOSE);
    
     //ThreadBoostUtils.sleep(6000);
    
View Full Code Here

public class TestJungGraphBoostUtils extends TestCaseWithLog
{

  public void testDisplayGraph() throws Exception
  {
    Graph graph = TestJungGraph.createSampleGraph();
    Window frame = JungGraphBoostUtils.displayGraph(graph, JFrame.DISPOSE_ON_CLOSE);
   
    //ThreadBoostUtils.sleep(6000);
    frame.dispose();
  }
View Full Code Here

       
        vertexMap.put(vertex, name);
    }

    counter = 0;
    Graph g = (Graph) graph;
    for ( Object edge: graph.getEdges())
    {
      Object source =  g.getSource(edge);
      Object dest = g.getDest(edge);
      result.append( "graph.addEdge(" + counter++ + ", " + vertexMap.get(source) + ", " + vertexMap.get( dest) + ");\n");
    }
   
    return result;
  }
View Full Code Here

TOP

Related Classes of edu.uci.ics.jung.graph.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.