Package statechum.DeterministicDirectedSparseGraph

Examples of statechum.DeterministicDirectedSparseGraph.VertexID


  }

  @Test
  public void testSizeOne4()
  {
    VertexID vert = VertexID.parseID("P21");
    final Attempt<VertexID,Long> map = createMapOne(vert,valueOne);
    Assert.assertNull( ((MapWithSearch<VertexID,Long>)map.getOurs()).findElementById(VertexID.parseID("P20")));
    Assert.assertNull( ((MapWithSearch<VertexID,Long>)map.getOurs()).findElementById(null));
    Assert.assertNull( ((MapWithSearch<VertexID,Long>)map.getOurs()).findElementById(VertexID.parseID("N20")));
    Assert.assertSame(vert, ((MapWithSearch<VertexID,Long>)map.getOurs()).findElementById(vert));
View Full Code Here


  }
 
  @Test
  public void testSizeTwo6()
  {
    VertexID vert = VertexID.parseID("P21"), vert2 = VertexID.parseID("P99");
    final Attempt<VertexID,Long> map = createMapTwo(vert,valueOne,vert2,valueTwo);
    Assert.assertNull( ((MapWithSearch<VertexID,Long>)map.getOurs()).findElementById(VertexID.parseID("P20")));
    Assert.assertNull( ((MapWithSearch<VertexID,Long>)map.getOurs()).findElementById(null));
    Assert.assertSame(vert, ((MapWithSearch<VertexID,Long>)map.getOurs()).findElementById(vert));
    Assert.assertSame(vert, ((MapWithSearch<VertexID,Long>)map.getOurs()).findElementById(VertexID.parseID("P21")));
View Full Code Here

  }
 
  @Test
  public void TestMapWithSearch0b()
  {
    VertexID [] collectionOfKeys = new VertexID[]{new VertexID(VertKind.POSITIVE,0),new VertexID(VertKind.POSITIVE,1),new VertexID(VertKind.POSITIVE,3),new VertexID(VertKind.POSITIVE,4)};
    final Attempt<VertexID,Long> map = createMap();
    for(int i=0;i<collectionOfKeys.length;++i)
    {
      map.put(collectionOfKeys[i], new Long(1000+i));
      for(int j=i+1;j < collectionOfKeys.length;++j)
      {
        Assert.assertFalse("j="+j+", key "+collectionOfKeys[j]+" should not exist",map.containsKey(collectionOfKeys[j]));
        Assert.assertNull(map.remove(collectionOfKeys[j]));
        Assert.assertNull( ((MapWithSearch<VertexID,Long>)map.getOurs()).findElementById(collectionOfKeys[j]) );
      }
      for(int j=0;j <= i;++j)
      {
        Assert.assertEquals(new Long(1000+i),map.get(collectionOfKeys[i]));
        Assert.assertSame(collectionOfKeys[j], ((MapWithSearch<VertexID,Long>)map.getOurs()).findElementById(new VertexID(collectionOfKeys[j])) );
      }
    }
  }
View Full Code Here

    CACHE_B_TYPE extends CachedData<TARGET_B_TYPE, CACHE_B_TYPE>>
    void completeMatrix(AbstractLearnerGraph<TARGET_A_TYPE, CACHE_A_TYPE> what,
        AbstractLearnerGraph<TARGET_B_TYPE, CACHE_B_TYPE> result)
  {
    AbstractLearnerGraph.copyGraphs(what, result);
    VertexID rejectID = result.nextID(false);
    result.pathroutines.completeGraph(rejectID);
    result.findVertex(rejectID).setColour(LearnerGraphND.ltlColour);
    result.findVertex(rejectID).setAccept(false);
  }
View Full Code Here

  }

  @Override
  public void setOrigState(VertID newState) {
    if (newState == null) origState = null;
    else origState = new VertexID(newState);
  }
View Full Code Here

      // Add relabelling: first, aTOb , then duplicates. If this is done in a different order
      // we might relabel a vertex to the name already in use and relabel will choke.
      for(Entry<CmpVertex,CmpVertex> entry:aTOb.entrySet())
      {
        VertexID from = entry.getKey().getID(), to = newBToOrig.get(entry.getValue()).getID();
        if (!from.equals(to))
          addRelabelling(from,to);
      }

      for(CmpVertex vert:duplicates)
        addRelabelling(vert.getID(), newBToOrig.get(vert).getID());
View Full Code Here

   */
  public static void addRejectVertices(LearnerGraph gr,String prefix, int number)
  {
    for(int i=-1;i<number;++i)
    {
      VertexID id = new VertexID(prefix+(i>=0?i:""));if (gr.findVertex(id) != null) throw new IllegalArgumentException("vertex already exists");
      CmpVertex newVertex = LearnerGraph.generateNewCmpVertex(id, gr.config);newVertex.setAccept(false);
      gr.transitionMatrix.put(newVertex, new TreeMap<String,CmpVertex>());
    }
  }
View Full Code Here

      Map<CmpVertex,CmpVertex> oldToNew = new HashMap<CmpVertex,CmpVertex>();

      // First, clone vertices
      for(CmpVertex state:graph.transitionMatrix.keySet())
      {
        VertexID newID = relabelling.get(state.getID());
        if (newID == null)
          oldToNew.put(state, AbstractLearnerGraph.cloneCmpVertex(state, result.config)); // clone
        else // copy under a different name
        {
          CmpVertex newVertex = AbstractLearnerGraph.generateNewCmpVertex(newID, result.config);// rename
View Full Code Here

  {
    CmpVertex vert = verticesUsed.get(name);

    if (vert == null)
    {// add new vertex
      vert = AbstractLearnerGraph.generateNewCmpVertex(new VertexID(name), config);
      vert.setAccept(name.startsWith("accept_"));vert.setColour(LearnerGraphND.ltlColour);
      matrixFromLTL.transitionMatrix.put(vert,matrixFromLTL.createNewRow());
      verticesUsed.put(name, vert);
    }
    return vert;
View Full Code Here

  }
 
  /** Adds the supplied prefix to vertex ID provided. */
  static void renameVertex(VertexID currID, String prefix,Map<VertexID,VertexID> oldVerticesToNew)
  {
    VertexID currentVertex = oldVerticesToNew.get(currID);
    VertexID newID = new VertexID(prefix+(currentVertex==null?"":currentVertex.toString()));
    if (oldVerticesToNew.containsKey(newID) || oldVerticesToNew.containsKey(newID))
      throw new IllegalArgumentException("duplicate vertex "+newID+" in outcome");
    oldVerticesToNew.put(currID,newID);
  }
View Full Code Here

TOP

Related Classes of statechum.DeterministicDirectedSparseGraph.VertexID

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.