Package edu.uci.ics.jung.graph

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


    Set<String>loopLabels = new HashSet<String>();
    boolean loopToR = r.getSuccessors().contains(r);
    boolean redAndBlueNeighbours = r.getNeighbors().contains(q);
    if(loopToR||redAndBlueNeighbours){ //there either exists a loop to r or will do if r and b merge
      if(loopToR){
        Edge e = findEdge(r, r);
        HashSet<String> labels = (HashSet<String>)e.getUserDatum(JUConstants.LABEL);
        loopLabels.addAll(labels);
      }
      if(redAndBlueNeighbours){
        Edge e = findEdge(r,q);
        HashSet<String> labels = (HashSet<String>)e.getUserDatum(JUConstants.LABEL);
        loopLabels.addAll(labels);
      }
    }
    wIt = w.iterator();
    while(wIt.hasNext()){
View Full Code Here


   */
  protected static HashSet<List<String>> getShortSuffixes(DirectedSparseGraph g, Vertex v){
    HashSet<List<String>> returnStrings = new HashSet<List<String>>();
    Iterator<Edge> outEdgeIt = v.getOutEdges().iterator();
    while(outEdgeIt.hasNext()){
      Edge e = outEdgeIt.next();
      if(DeterministicDirectedSparseGraph.isAccept(e.getOpposite(v))){
        ArrayList<Edge> l = new ArrayList<Edge>();
        l.add(e);
        returnStrings.addAll(getPaths(l));
      }
    }
View Full Code Here

   * @return
   */
  protected static Set<List<String>> getPaths(List<Edge> l){
    TreeMap<Integer,Set<List<String>>> returnSet = new TreeMap<Integer,Set<List<String>>>();// KIRR: this should not be done in this way since access to this map is not random - you only need the last element in which case simply storing the last set of lists is best
    for(int i=0;i<l.size();i++){// for each element of the source list
      Edge e = l.get(i);
      Set<String> labels = (Set<String>)e.getUserDatum(JUConstants.LABEL);
      Set<List<String>> strings = new HashSet<List<String>>();
      for(String s:labels)
      {
        if(i==0){
          List<String> string = new ArrayList<String>();
View Full Code Here

    Vertex init = DeterministicDirectedSparseGraph.findInitial(model);
    UnweightedShortestPath p = new UnweightedShortestPath(model);
    Iterator<Edge> pathIt =  ShortestPathUtils.getPath(p, init, q).iterator();
    List<String> list = new ArrayList<String>();
    while(pathIt.hasNext()){
      Edge e = pathIt.next();
      Set<String> s = (Set<String>)e.getUserDatum(JUConstants.LABEL);
      Object[] strings = s.toArray();
      list.add(strings[0].toString());
    }
     
    return list;
View Full Code Here

      DirectedSparseEdge eDash = new DirectedSparseEdge(e.getSource(), qDash);
      eDash.addUserDatum(JUConstants.LABEL, e.getUserDatum(JUConstants.LABEL), UserData.CLONE);
      if(!e.getSource().getSuccessors().contains(qDash))
        model.addEdge(eDash);
      else{
        Edge existing = findEdge(e.getSource(), qDash);
        Set<String> labels = (Set<String>)existing.getUserDatum(JUConstants.LABEL);// KIRR: if you use UserData.SHARED, you do not need to copy the result back using put
        labels.addAll((Set<String>)e.getUserDatum(JUConstants.LABEL));
        existing.setUserDatum(JUConstants.LABEL, labels, UserData.CLONE);
      }
      removeEdges.add(e);
    }
    Iterator<DirectedSparseEdge> outEdges = q.getOutEdges().iterator();
    while(outEdges.hasNext()){
      DirectedSparseEdge e = outEdges.next();
      DirectedSparseEdge eDash = new DirectedSparseEdge(qDash, e.getDest());
      eDash.addUserDatum(JUConstants.LABEL, e.getUserDatum(JUConstants.LABEL), UserData.CLONE);
      if(!qDash.getSuccessors().contains(e.getDest()))
        model.addEdge(eDash);
      else{
        Edge existing = findEdge(qDash, e.getDest());
        Set<String> labels = (Set<String>)existing.getUserDatum(JUConstants.LABEL);
        labels.addAll((Set<String>)e.getUserDatum(JUConstants.LABEL));
        existing.setUserDatum(JUConstants.LABEL, labels, UserData.CLONE);
      }
      removeEdges.add(e);
    }
    model.removeEdges(removeEdges);
    model.removeVertex(q);
View Full Code Here

      prefixes = getPaths(prefixEdges);
    }
    Set<List<String>> suffixes = computeSuffixes(tempRed, temp);
    List<List<String>> questions =new ArrayList<List<String>>();
    questions.addAll(mergePrefixWithSuffixes(prefixes, suffixes));
    Edge loopEdge = findEdge(tempRed, tempRed);
    if(loopEdge!=null){
      Collection<String> looplabels = (Collection<String>)loopEdge.getUserDatum(JUConstants.LABEL);
      questions.addAll(mergePrefixWithSuffixes(prefixes, looplabels,suffixes));
    }
   
    DirectedSparseGraph questionPrefixes = augmentPTA(DeterministicDirectedSparseGraph.initialise(), questions, true);
    Iterator<Vertex> questionIt = getEndPoints(questionPrefixes).iterator();
View Full Code Here

   
    DirectedSparseGraph gr = DifferenceVisualiser.ChangesToGraph.computeVisualisationParameters(grAerlang, difference);
    Map<String,String> edgeToColours = new TreeMap<String,String>();
    for(Object edgeObj:gr.getEdges())
    {
      Edge edge = (Edge)edgeObj;
      if (edge.containsUserDatumKey(JUConstants.DIFF))
        edgeToColours.put(edge.toString(), edge.getUserDatum(JUConstants.DIFF).toString());
    }
    Assert.assertEquals("{P1000-[a]->P1000=java.awt.Color[r=255,g=0,b=0], P1000-[b]->P1002=java.awt.Color[r=255,g=0,b=0], P1000-[c]->N1000=java.awt.Color[r=255,g=0,b=0], P1001-[a]->P1000=java.awt.Color[r=0,g=255,b=0], P1001-[b]->P1003=java.awt.Color[r=0,g=255,b=0], P1001-[d]->P1001=java.awt.Color[r=0,g=255,b=0], P1002-[c, d]->P1002=java.awt.Color[r=255,g=0,b=0], P1003-[a, c]->P1001=java.awt.Color[r=0,g=255,b=0]}",
        edgeToColours.toString());
  }
View Full Code Here

        Collection<String> existingLabels = (Collection<String>)e.getUserDatum(JUConstants.LABEL);
        g.removeEdge(e);

        // It is possible that there is already an edge between g.getSource Blue and newRed
        Iterator<DirectedSparseEdge> sourceOutIt = source.getOutEdges().iterator();
        Edge fromSourceToNewRed = null;
        while(sourceOutIt.hasNext() && fromSourceToNewRed == null)
        {
          DirectedSparseEdge out = sourceOutIt.next();if (out.getDest() == newRed) fromSourceToNewRed = out;
        }
        if (fromSourceToNewRed == null)
        {
          fromSourceToNewRed = new DirectedSparseEdge(source,newRed);
          fromSourceToNewRed.setUserDatum(JUConstants.LABEL, existingLabels, UserData.CLONE);// no need to clone this one since I'll delete the edge in a bit
          g.addEdge(fromSourceToNewRed);
        }
        else
          // there is already a transition from source to newRed, hence all we have to do is merge the new labels into it.
          ((Collection<String>)fromSourceToNewRed.getUserDatum(JUConstants.LABEL)).addAll( existingLabels );
         
      }

      // now the elements of mergedVertices are in terms of the copied graph.
      for(Vertex vert:(Set<Vertex>)g.getVertices())
View Full Code Here

        Collection<Label> existingLabels = (Collection<Label>)e.getUserDatum(JUConstants.LABEL);
        g.removeEdge(e);

        // It is possible that there is already an edge between g.getSource Blue and newRed
        Iterator<DirectedSparseEdge> sourceOutIt = source.getOutEdges().iterator();
        Edge fromSourceToNewRed = null;
        while(sourceOutIt.hasNext() && fromSourceToNewRed == null)
        {
          DirectedSparseEdge out = sourceOutIt.next();if (out.getDest() == newRed) fromSourceToNewRed = out;
        }
        if (fromSourceToNewRed == null)
        {
          fromSourceToNewRed = new DirectedSparseEdge(source,newRed);
          fromSourceToNewRed.setUserDatum(JUConstants.LABEL, existingLabels, UserData.CLONE);// no need to clone this one since I'll delete the edge in a bit
          g.addEdge(fromSourceToNewRed);
        }
        else
          // there is already a transition from source to newRed, hence all we have to do is merge the new labels into it.
          ((Collection<Label>)fromSourceToNewRed.getUserDatum(JUConstants.LABEL)).addAll( existingLabels );
         
      }

      // now the elements of mergedVertices are in terms of the copied graph.
      for(Vertex vert:(Set<Vertex>)g.getVertices())
View Full Code Here

        Collection<String> existingLabels = (Collection<String>)e.getUserDatum(JUConstants.LABEL);
        g.removeEdge(e);

        // It is possible that there is already an edge between g.getSource Blue and newRed
        Iterator<DirectedSparseEdge> sourceOutIt = source.getOutEdges().iterator();
        Edge fromSourceToNewRed = null;
        while(sourceOutIt.hasNext() && fromSourceToNewRed == null)
        {
          DirectedSparseEdge out = sourceOutIt.next();if (out.getDest() == newRed) fromSourceToNewRed = out;
        }
        if (fromSourceToNewRed == null)
        {
          fromSourceToNewRed = new DirectedSparseEdge(source,newRed);
          fromSourceToNewRed.setUserDatum(JUConstants.LABEL, existingLabels, UserData.CLONE);// no need to clone this one since I'll delete the edge in a bit
          g.addEdge(fromSourceToNewRed);
        }
        else
          // there is already a transition from source to newRed, hence all we have to do is merge the new labels into it.
          ((Collection<String>)fromSourceToNewRed.getUserDatum(JUConstants.LABEL)).addAll( existingLabels );
         
      }

      // now the elements of mergedVertices are in terms of the copied graph.
      for(Vertex vert:(Set<Vertex>)g.getVertices())
View Full Code Here

TOP

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

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.