Package statechum

Examples of statechum.StringVertex


  @Test
  public void testGraphConstruction2()
  {
    LearnerGraph expected = new LearnerGraph(confString);expected.initEmpty();
    LearnerGraph graph = new LearnerGraph(buildGraph("A--a-->B-b->C-c->A-b->B-a-#D","testConstruction2"),config);
    CmpVertex A = new StringVertex("A"), B = new StringVertex("B"), C = new StringVertex("C");
    CmpVertex D = new StringVertex("D");D.setAccept(false);
    expected.transitionMatrix.put(A, createLabelToStateMap(Arrays.asList(new String[] {"a","b"}),new StringVertex("B"),null));
    expected.transitionMatrix.put(B, createLabelToStateMap(Arrays.asList(new String[] {"b"}),new StringVertex("C"),createLabelToStateMap(Arrays.asList(new String[] {"a"}),D,null)));
    expected.transitionMatrix.put(C, createLabelToStateMap(Arrays.asList(new String[] {"c"}),new StringVertex("A"),null));
    expected.transitionMatrix.put(D, createLabelToStateMap(Collections.EMPTY_LIST,null,null));
    expected.init = expected.findVertex("A");
   
    assertEquals("A", graph.init.getID().toString());
    //Visualiser.updateFrame(graph.paths.getGraph(), expected.paths.getGraph());Visualiser.waitForKey();
View Full Code Here


  @Test
  public void testGraphConstruction3()
  {
    LearnerGraph expected = new LearnerGraph(confString);expected.initEmpty();
    LearnerGraph graph = new LearnerGraph(buildGraph("A--a-->B<-b--C-c->A-b->A-c->A\nB-d->B-p->C\nB-q->C\nB-r->C\n","testConstruction3"),config);
    CmpVertex A = new StringVertex("A"), B = new StringVertex("B"), C = new StringVertex("C");
    expected.transitionMatrix.put(A, createLabelToStateMap(Arrays.asList(new String[] {"b","c"}),new StringVertex("A"),createLabelToStateMap(Arrays.asList(new String[] {"a"}),B,null)));
    expected.transitionMatrix.put(B, createLabelToStateMap(Arrays.asList(new String[] {"d"}),B,createLabelToStateMap(Arrays.asList(new String[] {"r","p","q"}),C,null)));
    expected.transitionMatrix.put(C, createLabelToStateMap(Arrays.asList(new String[] {"b"}),B,createLabelToStateMap(Arrays.asList(new String[] {"c"}),A,null)));
    expected.init = expected.findVertex("A");
   
    assertEquals("A", graph.init.getID().toString());
View Full Code Here

  @Test
  public void testGraphConstruction4()
  {
    LearnerGraph expected = new LearnerGraph(confString);expected.initEmpty();
    LearnerGraph graph = new LearnerGraph(buildGraph("A--a-->B<-b--D-c->A-b->A-c->A\nB-d->B-p-#C\nB-q-#C\nB-r-#C\n","testConstruction4"),config);
    CmpVertex A = new StringVertex("A"), B = new StringVertex("B"), C = new StringVertex("C"),D = new StringVertex("D");
    C.setAccept(false);
    expected.transitionMatrix.put(A, createLabelToStateMap(Arrays.asList(new String[] {"b","c"}),new StringVertex("A"),createLabelToStateMap(Arrays.asList(new String[] {"a"}),B,null)));
    expected.transitionMatrix.put(B, createLabelToStateMap(Arrays.asList(new String[] {"d"}),B,createLabelToStateMap(Arrays.asList(new String[] {"r","p","q"}),C,null)));
    expected.transitionMatrix.put(D, createLabelToStateMap(Arrays.asList(new String[] {"b"}),B, createLabelToStateMap(Arrays.asList(new String[] {"c"}),A,null)));
    expected.transitionMatrix.put(C, createLabelToStateMap(Collections.EMPTY_LIST,null,null));
    expected.init = expected.findVertex("A");
    expected.findVertex("A").setAccept(true);
View Full Code Here

  @Test
  public void testGraphConstruction5()
  {
    LearnerGraph expected = new LearnerGraph(confString);expected.initEmpty();
    LearnerGraph graph = new LearnerGraph(buildGraph("A--a-->B-b-#C\nA-b->A-c->A\nB-d->B-p-#C\nB-q-#C\nB-r-#C\n","testConstruction5"),config);
    CmpVertex A = new StringVertex("A"), B = new StringVertex("B"), C = new StringVertex("C");
    C.setAccept(false);
    expected.transitionMatrix.put(A, createLabelToStateMap(Arrays.asList(new String[] {"b","c"}),A,createLabelToStateMap(Arrays.asList(new String[] {"a"}),B,null)));
    expected.transitionMatrix.put(B, createLabelToStateMap(Arrays.asList(new String[] {"d"}),B,createLabelToStateMap(Arrays.asList(new String[] {"b","r","p","q"}),C,null)));
    expected.transitionMatrix.put(C, createLabelToStateMap(Collections.EMPTY_LIST,null,null));
    expected.init = expected.findVertex("A");
   
View Full Code Here

  @Test
  public void testGraphConstruction6() // checks loop support
  {
    LearnerGraph expected = new LearnerGraph(confString);expected.initEmpty();
    LearnerGraph graph = new LearnerGraph(buildGraph("P-c->P<-b-Q_State<-a-P-b->P\nQ_State-a->Q_State","testConstruction6"),config);
    CmpVertex P = new StringVertex("P"), Q_State = new StringVertex("Q_State");
    expected.transitionMatrix.put(P, createLabelToStateMap(Arrays.asList(new String[] {"b","c"}),P,createLabelToStateMap(Arrays.asList(new String[] {"a"}),Q_State,null)));
    expected.transitionMatrix.put(Q_State, createLabelToStateMap(Arrays.asList(new String[] {"a"}),Q_State,createLabelToStateMap(Arrays.asList(new String[] {"b"}),P,null)));
    expected.init = expected.findVertex("P");
   
    assertEquals("P", graph.init.getID().toString());
View Full Code Here

  public static CmpVertex generateNewCmpVertex(VertexID name,Configuration conf)
  {
    synchronized(syncObj)
    {
      return conf.isLearnerUseStrings()?
          new StringVertex(name):
          new DeterministicVertex(name);     
    }   
  }
View Full Code Here

  public static LearnerGraph convertTableToFSMStructure(final int [][]tTable, final int []vFrom, int rejectNumber, Configuration config)
  {
    if (vFrom.length == 0 || tTable.length == 0) throw new IllegalArgumentException("array is zero-sized");
    int alphabetSize = tTable[vFrom[0]].length;
    if (alphabetSize == 0) throw new IllegalArgumentException("alphabet is zero-sized");
    CmpVertex stateName[] = new CmpVertex[tTable.length];for(int i=0;i < tTable.length;++i) stateName[i]=new StringVertex("S"+i);
    String inputName[] = new String[alphabetSize];for(int i=0;i < alphabetSize;++i) inputName[i]="i"+i;
    LearnerGraph fsm = new LearnerGraph(config);fsm.initEmpty();
    fsm.setInit(stateName[vFrom[0]]);
    Set<CmpVertex> statesUsed = new HashSet<CmpVertex>();
    for(int i=0;i<vFrom.length;++i)
View Full Code Here

  public final void testFSMStructureEquals5()
  {
    LearnerGraph a=new LearnerGraph(buildGraph("A-a->A-b->B\nB-b->B", "testFSMStructureEquals6"),config);
    LearnerGraph b=new LearnerGraph(buildGraph("A-a->A-b->B\nB-b->B", "testFSMStructureEquals6"),config);
   
    b.setInit(new StringVertex("B"));
    equalityTestingHelper(a,a,b,differentB);
  }
View Full Code Here

   * @param labels labels to distinguish between states.
   */
  private final static void addDistLabels(Map<CmpVertex,Map<CmpVertex,Set<String>>> distinguishingLabels, String stateA, String stateB, String [] labels)
  {
    Set<String> distLabels = new HashSet<String>();Map<CmpVertex,Set<String>> stateToDist = new HashMap<CmpVertex,Set<String>>();
    distLabels.clear();distLabels.addAll(Arrays.asList(labels));stateToDist.put(new StringVertex(stateB), distLabels);
    distinguishingLabels.put(new StringVertex(stateA),stateToDist);   
  }
View Full Code Here

   */
  @Test
  public final void testCreateLabelToStateMap8()
  {
    final Map<Label,List<CmpVertex>> trans = new HashMap<Label,List<CmpVertex>>();
    List<CmpVertex> A=Arrays.asList(new CmpVertex[]{new StringVertex("A")}),
      B=Arrays.asList(new CmpVertex[]{new StringVertex("B")});
    trans.put(lb("a"), A);trans.put(lb("b"), A);trans.put(lb("c"), B);
    checkForCorrectException(new whatToRun() { public @Override void run() {
      createLabelToStateMap(labelList(new String[] {"b","e"}), new StringVertex("A"),trans);
    }},IllegalArgumentException.class,"duplicate");
  }
View Full Code Here

TOP

Related Classes of statechum.StringVertex

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.