Examples of EdgeAnnotation


Examples of statechum.analysis.learning.rpnicore.PathRoutines.EdgeAnnotation

  {
    Configuration config = Configuration.getDefaultConfiguration().copy();config.setTransitionMatrixImplType(STATETREE.STATETREE_SLOWTREE);
    DirectedSparseGraph graph = GDVisualDemo.obtainDifferenceGraph(graphA,graphB, 0,false,config);
    @SuppressWarnings("unchecked")
    Map<String,String> labelling = (Map<String,String>)graph.getUserDatum(JUConstants.VERTEX);
    final EdgeAnnotation transitionAnnotation = (EdgeAnnotation)graph.getUserDatum(JUConstants.EDGE);
    //Visualiser.updateFrame(graph, null);Visualiser.waitForKey();
    return new Pair<String,String>(labelling.toString(),transitionAnnotation.toString());
  }
View Full Code Here

Examples of statechum.analysis.learning.rpnicore.PathRoutines.EdgeAnnotation

     * @param origGraph the source graph, as a Jung graph to permit both non-deterministic and deterministic graphs to be handled.
     * @return constructed graph
     */
    public DirectedSparseGraph getDifferenceGraph(DirectedSparseGraph origGraph)
    {
      final EdgeAnnotation transitionAnnotation = new EdgeAnnotation();
      DirectedSparseGraph outcome = origGraph;//new DirectedSparseGraph();
      for(Object constraint:outcome.getEdgeConstraints())
        if (constraint instanceof org.apache.commons.collections.functors.NotPredicate)
        {
          outcome.getEdgeConstraints().remove(constraint);break;
View Full Code Here

Examples of statechum.analysis.learning.rpnicore.PathRoutines.EdgeAnnotation

  private static Pair<String,String> differenceLabelling(String graphA,String graphB)
  {
    Configuration config = Configuration.getDefaultConfiguration();config.setTransitionMatrixImplType(STATETREE.STATETREE_SLOWTREE);
    DirectedSparseGraph graph = GDVisualDemo.obtainDifferenceGraph(graphA,graphB, 0,false,config);
    Map<String,String> labelling = (Map<String,String>)graph.getUserDatum(JUConstants.VERTEX);
    final EdgeAnnotation transitionAnnotation = (EdgeAnnotation)graph.getUserDatum(JUConstants.EDGE);
    return new Pair<String,String>(labelling.toString(),transitionAnnotation.toString());
  }
View Full Code Here

Examples of statechum.analysis.learning.rpnicore.PathRoutines.EdgeAnnotation

    final Map<VertID,VertID> oldVerticesToNew = new TreeMap<VertID,VertID>();
    final LearnerGraphND outcome = new LearnerGraphND(a,gdConfig);outcome.setName(outcome.getName()+"_diff");
    final LearnerGraphMutator<List<CmpVertex>,LearnerGraphNDCachedData> mutator =
      new LearnerGraphMutator<List<CmpVertex>,LearnerGraphNDCachedData>(outcome,gdConfig,null);

    final EdgeAnnotation transitionAnnotation = new EdgeAnnotation();
    final Map<StatePair,TransitionChanges> pairToNumberOfChanges = new TreeMap<StatePair,TransitionChanges>();
    for(Entry<CmpVertex,Map<Label,TARGET_A_TYPE>> entry:a.transitionMatrix.entrySet())
      for(Entry<Label,TARGET_A_TYPE> transition:entry.getValue().entrySet())
        for(CmpVertex target:a.getTargets(transition.getValue()))
        {
          TransitionChanges changes = pairToNumberOfChanges.get(new StatePair(entry.getKey(), target));
          if (changes == null)
          {
            changes = new TransitionChanges();pairToNumberOfChanges.put(new StatePair(entry.getKey(), target),changes);
          }
          changes.orig++;// we populate our map with the existing transitions
         
        }
    makeSteps();
    computeDifference(new PatchGraph() {
      protected Label copyVertexWithPrefix(String prefix, Label origLabel)
      {
        Label result = null;
        if (origLabel instanceof StringLabel)
          result = new StringLabel(prefix+origLabel);
        else
        if (origLabel instanceof ErlangLabel)
        {
          ErlangLabel oErl = (ErlangLabel)origLabel;
          result = new ErlangLabel(oErl.function,prefix+oErl.callName,
              oErl.input, oErl.expectedOutput);
        }
        else
          assert false;
       
        return result;
      }
     
      @Override
      public void addTransition(CmpVertex from, Label origLabel, CmpVertex to)
      {
        Label label = copyVertexWithPrefix("ADD_",origLabel);
        mutator.addTransition(from, label, to);
        TransitionChanges changes = pairToNumberOfChanges.get(new StatePair(from,to));
        if (changes == null)
        {
          changes = new TransitionChanges();pairToNumberOfChanges.put(new StatePair(from,to),changes);
        }
        changes.added++;
      }

      @Override
      public void removeTransition(CmpVertex from, Label origLabel, CmpVertex to)
      {
        Label label = copyVertexWithPrefix("REM_",origLabel);
        mutator.removeTransition(from, origLabel, to);// remove the original transition
        mutator.addTransition(from, label, to);// and add the renamed one
        TransitionChanges changes = pairToNumberOfChanges.get(new StatePair(from,to));
        if (changes == null)
        {
          changes = new TransitionChanges();pairToNumberOfChanges.put(new StatePair(from,to),changes);
        }
        changes.removed++;
      }

      @Override
      public void setInitial(CmpVertex vertex)
      {
        mutator.setInitial(vertex);
      }

      @Override
      public void addToCompatibility(@SuppressWarnings("unused") CmpVertex astate,
          @SuppressWarnings("unused") CmpVertex bstate, @SuppressWarnings("unused") JUConstants.PAIRCOMPATIBILITY value) {
        // does not do anything
      }

      @Override
      public void addRelabelling(VertID astate, VertID bstate) {
        renameVertex(astate, "["+bstate+"] ",oldVerticesToNew);
      }

      @Override
      public void addVertex(CmpVertex vertex) {
        mutator.addNewVertex(vertex);
      }

      @SuppressWarnings("unused")
      @Override
      public void removeFromCompatibility(CmpVertex astate, CmpVertex bstate, JUConstants.PAIRCOMPATIBILITY value) {
        // does not do anything
      }
    });

    for(Entry<StatePair,TransitionChanges> pc:pairToNumberOfChanges.entrySet())
    {
      CmpVertex from = pc.getKey().getQ(), to = pc.getKey().getR();
      Map<Label,Map<String,Color>> lbl = transitionAnnotation.get(from.getStringId());
      if (lbl == null)
      {
        lbl = new TreeMap<Label,Map<String,Color>>();transitionAnnotation.put(from.getStringId(), lbl);
      }
      for(Entry<Label,List<CmpVertex>> transition:outcome.transitionMatrix.get(from).entrySet())
        for(CmpVertex target:outcome.getTargets(transition.getValue()))
          if (to.equals(target))
          {
View Full Code Here

Examples of statechum.analysis.learning.rpnicore.PathRoutines.EdgeAnnotation

    final Map<VertexID,VertexID> oldVerticesToNew = new TreeMap<VertexID,VertexID>();
    final LearnerGraphND outcome = new LearnerGraphND(a,gdConfig);
    final LearnerGraphMutator<List<CmpVertex>,LearnerGraphNDCachedData> mutator =
      new LearnerGraphMutator<List<CmpVertex>,LearnerGraphNDCachedData>(outcome,gdConfig,null);

    final EdgeAnnotation transitionAnnotation = new EdgeAnnotation();
    makeSteps();
    computeDifference(new PatchGraph() {
      /** Annotates the supplied transition with a specific label and colour.
       *
       * @param from source state
       * @param label transition label
       * @param to target state
       * @param color colour to put on that transition.
       */
      private void addTransitionAnnotation(CmpVertex from, Label label, CmpVertex to,Color colour)
      {
        String fromString = from.getID().toString();
        Map<Label,Map<String,Color>> lbl = transitionAnnotation.get(fromString);
        if (lbl == null)
        {
          lbl = new TreeMap<Label,Map<String,Color>>();transitionAnnotation.put(fromString, lbl);
        }
        Map<String,Color> targetToColour = lbl.get(label);
        if (targetToColour == null)
        {// this is the first annotation for the specific target state
          targetToColour = new TreeMap<String,Color>();lbl.put(label,targetToColour);
View Full Code Here

Examples of statechum.analysis.learning.rpnicore.PathRoutines.EdgeAnnotation

    final Map<VertID,VertID> oldVerticesToNew = new TreeMap<VertID,VertID>();
    final LearnerGraphND outcome = new LearnerGraphND(a,gdConfig);outcome.setName(outcome.getName()+"_diff");
    final LearnerGraphMutator<List<CmpVertex>,LearnerGraphNDCachedData> mutator =
      new LearnerGraphMutator<List<CmpVertex>,LearnerGraphNDCachedData>(outcome,gdConfig,null);

    final EdgeAnnotation transitionAnnotation = new EdgeAnnotation();
    final Map<StatePair,TransitionChanges> pairToNumberOfChanges = new TreeMap<StatePair,TransitionChanges>();
    for(Entry<CmpVertex,Map<Label,TARGET_A_TYPE>> entry:a.transitionMatrix.entrySet())
      for(Entry<Label,TARGET_A_TYPE> transition:entry.getValue().entrySet())
        for(CmpVertex target:a.getTargets(transition.getValue()))
        {
          TransitionChanges changes = pairToNumberOfChanges.get(new StatePair(entry.getKey(), target));
          if (changes == null)
          {
            changes = new TransitionChanges();pairToNumberOfChanges.put(new StatePair(entry.getKey(), target),changes);
          }
          changes.orig++;// we populate our map with the existing transitions
         
        }
    makeSteps();
    computeDifference(new PatchGraph() {
      protected Label copyVertexWithPrefix(String prefix, Label origLabel)
      {
        Label result = null;
        if (origLabel instanceof StringLabel)
          result = new StringLabel(prefix+origLabel);
        else
        if (origLabel instanceof ErlangLabel)
        {
          ErlangLabel oErl = (ErlangLabel)origLabel;
          result = new ErlangLabel(oErl.function,prefix+oErl.callName,
              oErl.input, oErl.expectedOutput);
        }
        else
          assert false;
       
        return result;
      }
     
      @Override
      public void addTransition(CmpVertex from, Label origLabel, CmpVertex to)
      {
        Label label = copyVertexWithPrefix("ADD_",origLabel);
        mutator.addTransition(from, label, to);
        TransitionChanges changes = pairToNumberOfChanges.get(new StatePair(from,to));
        if (changes == null)
        {
          changes = new TransitionChanges();pairToNumberOfChanges.put(new StatePair(from,to),changes);
        }
        changes.added++;
      }

      @Override
      public void removeTransition(CmpVertex from, Label origLabel, CmpVertex to)
      {
        Label label = copyVertexWithPrefix("REM_",origLabel);
        mutator.removeTransition(from, origLabel, to);// remove the original transition
        mutator.addTransition(from, label, to);// and add the renamed one
        TransitionChanges changes = pairToNumberOfChanges.get(new StatePair(from,to));
        if (changes == null)
        {
          changes = new TransitionChanges();pairToNumberOfChanges.put(new StatePair(from,to),changes);
        }
        changes.removed++;
      }

      @Override
      public void setInitial(CmpVertex vertex)
      {
        mutator.setInitial(vertex);
      }

      @Override
      public void addToCompatibility(@SuppressWarnings("unused") CmpVertex astate,
          @SuppressWarnings("unused") CmpVertex bstate, @SuppressWarnings("unused") JUConstants.PAIRCOMPATIBILITY value) {
        // does not do anything
      }

      @Override
      public void addRelabelling(VertID astate, VertID bstate) {
        renameVertex(astate, "["+bstate+"] ",oldVerticesToNew);
      }

      @Override
      public void addVertex(CmpVertex vertex) {
        mutator.addNewVertex(vertex);
      }

      @SuppressWarnings("unused")
      @Override
      public void removeFromCompatibility(CmpVertex astate, CmpVertex bstate, JUConstants.PAIRCOMPATIBILITY value) {
        // does not do anything
      }
    });

    for(Entry<StatePair,TransitionChanges> pc:pairToNumberOfChanges.entrySet())
    {
      CmpVertex from = pc.getKey().getQ(), to = pc.getKey().getR();
      Map<Label,Map<String,Color>> lbl = transitionAnnotation.get(from.getStringId());
      if (lbl == null)
      {
        lbl = new TreeMap<Label,Map<String,Color>>();transitionAnnotation.put(from.getStringId(), lbl);
      }
      for(Entry<Label,List<CmpVertex>> transition:outcome.transitionMatrix.get(from).entrySet())
        for(CmpVertex target:outcome.getTargets(transition.getValue()))
          if (to.equals(target))
          {
View Full Code Here

Examples of statechum.analysis.learning.rpnicore.PathRoutines.EdgeAnnotation

     * @param origGraph the source graph, as a Jung graph to permit both non-deterministic and deterministic graphs to be handled.
     * @return constructed graph
     */
    public DirectedSparseGraph getDifferenceGraph(DirectedSparseGraph origGraph)
    {
      final EdgeAnnotation transitionAnnotation = new EdgeAnnotation();
      DirectedSparseGraph outcome = origGraph;//new DirectedSparseGraph();
      for(Object constraint:outcome.getEdgeConstraints())
        if (constraint instanceof org.apache.commons.collections.functors.NotPredicate)
        {
          outcome.getEdgeConstraints().remove(constraint);break;
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.