Package edu.uci.ics.jung.graph

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


   * @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

        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

          for(CmpVertex target:transition.getValue())
          {
            DeterministicVertex targetVertex = DeterministicDirectedSparseGraph.findVertexNamed(target,graphToUpdate);
            if (targetVertex == null)
              throw new IllegalArgumentException("target state in diff is not known, looking at "+target);
            Edge e=DeterministicDirectedSparseGraph.findEdge(fromVertex, targetVertex);
            if (e == null)
              throw new IllegalArgumentException("edge in diff was not found");
           
            Set<Label> labels = ((Set<Label>)e.getUserDatum(JUConstants.LABEL));
            labels.remove(transition.getKey());if (labels.isEmpty()) graphToUpdate.removeEdge(e);
          }
      }
    }
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

  public static Collection<Label> getAlphabetForEdges(Collection<Edge> edges){
    Set<Label> alphabet = new TreeSet<Label>();
    Iterator<Edge> edgeIt = edges.iterator();
    while(edgeIt.hasNext()){
      Edge e = (edgeIt.next());
      alphabet.addAll((Collection<Label>)e.getUserDatum(JUConstants.LABEL));
    }
    return alphabet;
  }
View Full Code Here

    Set<Label>loopLabels = new TreeSet<Label>();
    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);
        Set<Label> labels = (Set<Label>)e.getUserDatum(JUConstants.LABEL);
        loopLabels.addAll(labels);
      }
      if(redAndBlueNeighbours){
        Edge e = findEdge(r,q);
        Set<Label> labels = (Set<Label>)e.getUserDatum(JUConstants.LABEL);
        loopLabels.addAll(labels);
      }
    }
    wIt = w.iterator();
    while(wIt.hasNext()){
View Full Code Here

   */
  protected static Set<List<Label>> getShortSuffixes(@SuppressWarnings("unused") DirectedSparseGraph g, Vertex v){
    Set<List<Label>> returnStrings = new LinkedHashSet<List<Label>>();
    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<Label>> getPaths(List<Edge> l){
    TreeMap<Integer,Set<List<Label>>> returnSet = new TreeMap<Integer,Set<List<Label>>>();// 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<Label> labels = (Set<Label>)e.getUserDatum(JUConstants.LABEL);
      Set<List<Label>> strings = new HashSet<List<Label>>();
      for(Label s:labels)
      {
        if(i==0){
          List<Label> string = new LinkedList<Label>();
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.