Package edu.uci.ics.jung.graph.impl

Examples of edu.uci.ics.jung.graph.impl.DirectedSparseEdge


      Vertex v = queueIt.next();
      Set<DirectedSparseEdge> edges = v.getOutEdges();
      Iterator<DirectedSparseEdge> edgeIt = edges.iterator();
      Map<String,DirectedSparseEdge> doneLabels = new HashMap<String,DirectedSparseEdge>();
      while(edgeIt.hasNext()){
        DirectedSparseEdge e = edgeIt.next();
        Set<String> labels = (Set<String>)e.getUserDatum(JUConstants.LABEL);
        Iterator<String> labelIt = labels.iterator();
        while(labelIt.hasNext()){
          String label = labelIt.next();
          if(doneLabels.get(label)==null)
            doneLabels.put(label, e);
          else {
            DirectedSparseEdge eDash = doneLabels.get(label);
            OrigStatePair p = null;
            if(DeterministicDirectedSparseGraph.isInitial(eDash.getDest()))
              p = new OrigStatePair(e.getDest(), eDash.getDest());
            else
              p = new OrigStatePair(eDash.getDest(),e.getDest());
            if(!different(p)) // KIRR: strange - the two should never be different if the original pair to choose was selected properly
              return p;
          }
        }
      }
View Full Code Here


    if(different(blueRed))
        return -1;

    Iterator<DirectedSparseEdge> edgesOut = blueRed.getQ().getOutEdges().iterator();
    while(edgesOut.hasNext()){
      DirectedSparseEdge e = edgesOut.next();
      if(this.doneEdges.contains(e))
        continue;
     
      doneEdges.add(e);
      HashSet<String> labels = (HashSet<String>)e.getUserDatum(JUConstants.LABEL);
      Iterator<String> labelIt = labels.iterator();
      while(labelIt.hasNext()){
        List<String> string = new ArrayList<String>();
        string.add(labelIt.next());
        Vertex qi = e.getDest();
        Vertex qj = getVertex(original,blueRed.getR(), string);
        OrigStatePair newPair = new OrigStatePair(qi, qj);
        if(qj!=null){
          int equivalent = computeScore(original, newPair);
          if(equivalent<0){
View Full Code Here

       
        if(existing == null){
          pta.addVertex(newVertex);
          Vertex previous;
          previous = getVertex(pta, string.subList(0, i-1));// for i==1, getVertex will return the initial vertex
          DirectedSparseEdge e = new DirectedSparseEdge(previous, newVertex);
          Set<String> labels = new HashSet<String>();
          labels.add(string.get(i-1));
          e.addUserDatum(JUConstants.LABEL, labels, UserData.CLONE);
          pta.addEdge(e);
        }
        else
          if (different(new OrigStatePair(existing,newVertex)))
          {
View Full Code Here

    if (current == null)
      return null;
   
    for(int i = 0;i<string.size();i++){
      String label = string.get(i);
      DirectedSparseEdge edge = getEdgeWithLabel(current.getOutEdges(), label);
      if(edge == null)
        return null;
      current = edge.getDest();
    }
    return current;
  }
View Full Code Here

  }

  public static DirectedSparseEdge getEdgeWithLabel(Set<DirectedSparseEdge> edges, String label){
    Iterator<DirectedSparseEdge> edgeIt = edges.iterator();
    while(edgeIt.hasNext()){
      DirectedSparseEdge e = edgeIt.next();
      Set<String> labels = (Set<String>)e.getUserDatum(JUConstants.LABEL);
      if(labels.contains(label))
        return e;
    }
    return null;
  }
View Full Code Here

  }

  public static Edge findEdge(Vertex from, Vertex to){
    Iterator<DirectedSparseEdge> edgesOut = from.getOutEdges().iterator();
    while(edgesOut.hasNext()){
      DirectedSparseEdge current = edgesOut.next();
      if(current.getDest().equals(to))
        return current;
    }
    return null;
  }
View Full Code Here

  public static Set<List<String>> computeSuffixes(Vertex v, DirectedSparseGraph model){
    Set<List<String>> returnSet = new HashSet<List<String>>();
    DijkstraShortestPath p = new DijkstraShortestPath(model);
    Iterator<DirectedSparseEdge> edgeIt = model.getEdges().iterator();
    while(edgeIt.hasNext()){
      DirectedSparseEdge e = edgeIt.next();
      List<Edge> sp = null;
      sp = p.getPath(v, e.getSource());
      if(sp!=null){
        if(!sp.isEmpty()){
          sp.add(e);
          Set<List<String>> paths = getPaths(sp);
          returnSet.addAll(paths);
        }
        else if(e.getSource().equals(v)) { //&&(e.getDest().equals(v))){ // KIRR: BUG FIXED
          sp.add(e);
          Set<List<String>> paths = getPaths(sp);
          returnSet.addAll(paths);
        }
      }
View Full Code Here

      e.removeUserDatum(JUConstants.LABEL);
      Iterator<String> labelIt = labels.iterator();
      e.addUserDatum(EDGE, labelIt.next(), UserData.SHARED);
      while(labelIt.hasNext())
      {
        DirectedSparseEdge newEdge = new DirectedSparseEdge(e.getSource(),e.getDest());
        newEdge.setUserDatum(EDGE, labelIt.next(), UserData.SHARED);
        newEdges.add(newEdge);
      }
    }
   
    for(Edge e:newEdges)
View Full Code Here

  {
    Iterator<DirectedSparseEdge> edgeIt = (Iterator<DirectedSparseEdge>)g.getEdges().iterator();
    FSMStructure extractedFSM = new FSMStructure();
    while(edgeIt.hasNext())
    {
      DirectedSparseEdge edge = edgeIt.next();
      Vertex fromVertex = edge.getSource(), toVertex = edge.getDest();
      String from = (String)fromVertex.getUserDatum(JUConstants.LABEL),
        to = (String)toVertex.getUserDatum(JUConstants.LABEL);
      Map<String,String> labelToTargetState = extractedFSM.trans.get(from);
      if (labelToTargetState == null)
      {
        labelToTargetState = new TreeMap<String,String>();extractedFSM.trans.put(from, labelToTargetState);
      }

      createLabelToStateMap((Set<String>)edge.getUserDatum(JUConstants.LABEL),to,labelToTargetState);
    }
   
    Iterator<Vertex> vertexIt = (Iterator<Vertex>)g.getVertices().iterator();
    while(vertexIt.hasNext())
    {
View Full Code Here

    {
      Vertex v = vertexIt.next();
      outLabels.clear();
      Iterator<DirectedSparseEdge>outEdgeIt = v.getOutEdges().iterator();
      while(outEdgeIt.hasNext()){
        DirectedSparseEdge outEdge = outEdgeIt.next();
        outLabels.addAll( (Set<String>)outEdge.getUserDatum(JUConstants.LABEL) );
      }
      transitionsToBeAdded = !alphabet.equals(outLabels);
    }
   
    if (transitionsToBeAdded)
    {
      // third pass - adding transitions
      g.addVertex(rejectVertex);
      vertexIt = (Iterator<Vertex>)g.getVertices().iterator();
      while(vertexIt.hasNext())
      {
        Vertex v = vertexIt.next();
        if (v != rejectVertex)
        {// no transitions should start from the reject vertex
          Set<String> outgoingLabels = new TreeSet<String>();outgoingLabels.addAll(alphabet);
         
          Iterator<DirectedSparseEdge>outEdgeIt = v.getOutEdges().iterator();
          while(outEdgeIt.hasNext()){
            DirectedSparseEdge outEdge = outEdgeIt.next();
            outgoingLabels.removeAll( (Set<String>)outEdge.getUserDatum(JUConstants.LABEL) );
          }
          if (!outgoingLabels.isEmpty())
          {
            // add a transition
            DirectedSparseEdge edge = new DirectedSparseEdge(v,rejectVertex);
            edge.addUserDatum(JUConstants.LABEL, outgoingLabels, UserData.CLONE);
            g.addEdge(edge);
          }
        }
      }
    }
View Full Code Here

TOP

Related Classes of edu.uci.ics.jung.graph.impl.DirectedSparseEdge

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.