Examples of DirectedSparseEdge


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

    init.setColour(JUConstants.RED);

    Iterator<DirectedSparseEdge> edgeIter = g.getEdges().iterator();
    while(edgeIter.hasNext())
    { 
      DirectedSparseEdge edge = edgeIter.next();
      Map<String,CmpVertex> outgoing = transitionMatrix.get(origToCmp.get(edge.getSource()));
      assert origToCmp.containsKey(edge.getDest());// this cannot fail if we handle normal Jung graphs which will never let me add an edge with vertex not in the graph
      // The line below aims to ensure that inputs are evaluated by computeStateScore in a specific order, which in conjunction with the visited set of computeStateScore permits emulating a bug in computeScore
      createLabelToStateMap((Set<String>)edge.getUserDatum(JUConstants.LABEL),origToCmp.get(edge.getDest()),outgoing);
    }
  }
View Full Code Here

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

    {
      Vertex v = vertexIt.next();
      outLabels.clear();
      Iterator<DirectedSparseEdge>outEdgeIt = v.getOutEdges().iterator();
      while(outEdgeIt.hasNext()){
        DirectedSparseEdge outEdge = outEdgeIt.next();
        outLabels.addAll( (Set<Label>)outEdge.getUserDatum(JUConstants.LABEL) );
      }
      transitionsToBeAdded = !alphabet.equals(outLabels);
    }
   
    if (transitionsToBeAdded)
    {
      // third pass - adding transitions
      g.addVertex(rejectVertex);
      vertexIt = g.getVertices().iterator();
      while(vertexIt.hasNext())
      {
        Vertex v = vertexIt.next();
        if (v != rejectVertex)
        {// no transitions should start from the reject vertex
          Set<Label> outgoingLabels = new TreeSet<Label>();outgoingLabels.addAll(alphabet);
         
          Iterator<DirectedSparseEdge>outEdgeIt = v.getOutEdges().iterator();
          while(outEdgeIt.hasNext()){
            DirectedSparseEdge outEdge = outEdgeIt.next();
            outgoingLabels.removeAll( (Set<Label>)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

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

    Map<VertID,DeterministicVertex> newVertices = new TreeMap<VertID,DeterministicVertex>();
    for(DirectedSparseEdge e:(Set<DirectedSparseEdge>)g.getEdges())
    {
      DeterministicVertex newSrc = DeterministicDirectedSparseGraph.copyVertex(newVertices,result,e.getSource()),
        newDst = DeterministicDirectedSparseGraph.copyVertex(newVertices, result, e.getDest());
      DirectedSparseEdge newEdge = new DirectedSparseEdge(newSrc,newDst);
      Set<Label> origLabels = (Set<Label>)e.getUserDatum(JUConstants.LABEL);
      TreeSet<Label> copiedLabels = new TreeSet<Label>();copiedLabels.addAll(origLabels);
      newEdge.addUserDatum(JUConstants.LABEL, copiedLabels, UserData.SHARED);
      result.addEdge(newEdge);
    }
    return result;
  }
View Full Code Here

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

 
  public static Edge findEdge(Vertex from, Vertex to){
    @SuppressWarnings("unchecked")
    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

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

      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

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

        // 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())
        if (mergedVertices.containsKey(vert))
        {// there are some vertices to merge with this one.
          usedInputs.clear();usedInputs.addAll(s.transitionMatrix.get(vert).keySet());
          for(CmpVertex toMerge:mergedVertices.get(vert))
          {// for every input, I'll have a unique target state - this is a feature of PTA
           // For this reason, every if multiple branches of PTA get merged, there will be no loops or parallel edges.
          // As a consequence, it is safe to assume that each input/target state combination will lead to a new state.
            Set<String> inputsFrom_toMerge = s.transitionMatrix.get(toMerge).keySet();
            for(String input:inputsFrom_toMerge)
              if (!usedInputs.contains(input))
              {
                Set<String> labels = new HashSet<String>();labels.add(input);
                DeterministicVertex targetVert = (DeterministicVertex)s.transitionMatrix.get(toMerge).get(input);
                DirectedSparseEdge newEdge = new DirectedSparseEdge(vert,targetVert);
                newEdge.addUserDatum(JUConstants.LABEL, labels, UserData.CLONE);
                g.removeEdges(targetVert.getInEdges());g.addEdge(newEdge);
              }
            usedInputs.addAll(inputsFrom_toMerge);
          }
        }
View Full Code Here

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

        // 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())
        if (mergedVertices.containsKey(vert))
        {// there are some vertices to merge with this one.
          usedInputs.clear();usedInputs.addAll(s.transitionMatrix.get(vert).keySet());
          for(CmpVertex toMerge:mergedVertices.get(vert))
          {// for every input, I'll have a unique target state - this is a feature of PTA
           // For this reason, every if multiple branches of PTA get merged, there will be no loops or parallel edges.
          // As a consequence, it is safe to assume that each input/target state combination will lead to a new state.
            Set<Label> inputsFrom_toMerge = s.transitionMatrix.get(toMerge).keySet();
            for(Label input:inputsFrom_toMerge)
              if (!usedInputs.contains(input))
              {
                Set<Label> labels = new HashSet<Label>();
                                                                labels.add(input);
                DeterministicVertex targetVert = (DeterministicVertex)s.transitionMatrix.get(toMerge).get(input);
                DirectedSparseEdge newEdge = new DirectedSparseEdge(vert,targetVert);
                newEdge.addUserDatum(JUConstants.LABEL, labels, UserData.CLONE);
                g.removeEdges(targetVert.getInEdges());g.addEdge(newEdge);
              }
            usedInputs.addAll(inputsFrom_toMerge);
          }
        }
View Full Code Here

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

    {
      Vertex v = vertexIt.next();
      outLabels.clear();
      Iterator<DirectedSparseEdge>outEdgeIt = v.getOutEdges().iterator();
      while(outEdgeIt.hasNext()){
        DirectedSparseEdge outEdge = outEdgeIt.next();
        outLabels.addAll( (Set<Label>)outEdge.getUserDatum(JUConstants.LABEL) );
      }
      transitionsToBeAdded = !alphabet.equals(outLabels);
    }
   
    if (transitionsToBeAdded)
    {
      // third pass - adding transitions
      g.addVertex(rejectVertex);
      vertexIt = g.getVertices().iterator();
      while(vertexIt.hasNext())
      {
        Vertex v = vertexIt.next();
        if (v != rejectVertex)
        {// no transitions should start from the reject vertex
          Set<Label> outgoingLabels = new TreeSet<Label>();outgoingLabels.addAll(alphabet);
         
          Iterator<DirectedSparseEdge>outEdgeIt = v.getOutEdges().iterator();
          while(outEdgeIt.hasNext()){
            DirectedSparseEdge outEdge = outEdgeIt.next();
            outgoingLabels.removeAll( (Set<Label>)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

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

    {
      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

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

    Map<VertID,DeterministicVertex> newVertices = new TreeMap<VertID,DeterministicVertex>();
    for(DirectedSparseEdge e:(Set<DirectedSparseEdge>)g.getEdges())
    {
      DeterministicVertex newSrc = DeterministicDirectedSparseGraph.copyVertex(newVertices,result,e.getSource()),
        newDst = DeterministicDirectedSparseGraph.copyVertex(newVertices, result, e.getDest());
      DirectedSparseEdge newEdge = new DirectedSparseEdge(newSrc,newDst);
      Set<Label> origLabels = (Set<Label>)e.getUserDatum(JUConstants.LABEL);
      TreeSet<Label> copiedLabels = new TreeSet<Label>();copiedLabels.addAll(origLabels);
      newEdge.addUserDatum(JUConstants.LABEL, copiedLabels, UserData.SHARED);
      result.addEdge(newEdge);
    }
    return result;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.