Package edu.uci.ics.jung.graph.util

Examples of edu.uci.ics.jung.graph.util.Pair


  @Override
  public Pair<V> getEndpoints(E arg0)
  {
   
    return new Pair(g.getEdgeSource(arg0),g.getEdgeTarget(arg0));
  }
View Full Code Here


        graph.addVertex(clusterGraph);
       
        //add all edges from the inGraph, unless both endpoints of
        // the edge are in the cluster
        for(Object e : (Collection<?>)inGraph.getEdges()) {
            Pair endpoints = inGraph.getEndpoints(e);
            // don't add edges whose endpoints are both in the cluster
            if(cluster.containsAll(endpoints) == false) {

                if(cluster.contains(endpoints.getFirst())) {
                  graph.addEdge(e, clusterGraph, endpoints.getSecond(), inGraph.getEdgeType(e));

                } else if(cluster.contains(endpoints.getSecond())) {
                  graph.addEdge(e, endpoints.getFirst(), clusterGraph, inGraph.getEdgeType(e));

                } else {
                  graph.addEdge(e,endpoints.getFirst(), endpoints.getSecond(), inGraph.getEdgeType(e));
                }
            }
        }
        return graph;
    }
View Full Code Here

        // put all clusterGraph vertices and edges into the new Graph
        for(Object v : cluster) {
            graph.addVertex(v);
            for(Object edge : clusterGraph.getIncidentEdges(v)) {
                Pair endpoints = clusterGraph.getEndpoints(edge);
                graph.addEdge(edge, endpoints.getFirst(), endpoints.getSecond(), clusterGraph.getEdgeType(edge));
            }
        }
        // add all the vertices from the current graph except for
        // the cluster we are expanding
        for(Object v : inGraph.getVertices()) {
            if(v.equals(clusterGraph) == false) {
                graph.addVertex(v);
            }
        }

        // now that all vertices have been added, add the edges,
        // ensuring that no edge contains a vertex that has not
        // already been added
        for(Object v : inGraph.getVertices()) {
            if(v.equals(clusterGraph) == false) {
                for(Object edge : inGraph.getIncidentEdges(v)) {
                    Pair endpoints = inGraph.getEndpoints(edge);
                    Object v1 = endpoints.getFirst();
                    Object v2 = endpoints.getSecond();
                     if(cluster.containsAll(endpoints) == false) {
                        if(clusterGraph.equals(v1)) {
                            // i need a new v1
                            Object originalV1 = originalGraph.getEndpoints(edge).getFirst();
                            Object newV1 = findVertex(graph, originalV1);
View Full Code Here

        }
        for(Object v : picked) {
          clusterGraph.addVertex(v);
            Collection edges = inGraph.getIncidentEdges(v);
            for(Object edge : edges) {
                Pair endpoints = inGraph.getEndpoints(edge);
                Object v1 = endpoints.getFirst();
                Object v2 = endpoints.getSecond();
                if(picked.containsAll(endpoints)) {
                    clusterGraph.addEdge(edge, v1, v2, inGraph.getEdgeType(edge));
                }
            }
        }
View Full Code Here

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

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

TOP

Related Classes of edu.uci.ics.jung.graph.util.Pair

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.