Package statechum.DeterministicDirectedSparseGraph

Examples of statechum.DeterministicDirectedSparseGraph.DeterministicVertex


 
  /** Tests that types are correctly converted. */
  @Test
  public final void testAddUserData_highlight2()
  {
    DeterministicVertex vA=new DeterministicVertex("a");
    Assert.assertFalse(vA.isHighlight());
    vA.addUserDatum("highlIght", "tRue", UserData.SHARED);Assert.assertTrue(vA.isHighlight());
    vA.setUserDatum("hiGhlight", "falsE", UserData.SHARED);Assert.assertFalse(vA.isHighlight());

    DeterministicVertex vS=new DeterministicVertex("a");
    vS.setUserDatum("higHlight", "faLse", UserData.SHARED);Assert.assertFalse(vS.isHighlight());
  }
View Full Code Here


  }

  @Test
  public void testAddEdge1()
  {
    DeterministicVertex vA = (DeterministicVertex) DeterministicDirectedSparseGraph.findVertex(JUConstants.LABEL,VertexID.parseID("C"),gen.machine),
    vB = (DeterministicVertex) DeterministicDirectedSparseGraph.findVertex(JUConstants.LABEL,VertexID.parseID("B"),gen.machine);

    LearnerGraph outcome = new LearnerGraph(gen.machine,Configuration.getDefaultConfiguration());
    Assert.assertEquals(0,outcome.getTransitionMatrix().get(outcome.findVertex(VertexID.parseID("C"))).size());
    Assert.assertTrue(gen.addEdgeInternal(vA, vB));// this adds a numeric label
View Full Code Here

 
  /** Parallel edge. */
  @Test
  public void testAddEdge2()
  {
    DeterministicVertex vA = (DeterministicVertex) DeterministicDirectedSparseGraph.findVertex(JUConstants.LABEL,VertexID.parseID("A"),gen.machine),
    vB = (DeterministicVertex) DeterministicDirectedSparseGraph.findVertex(JUConstants.LABEL,VertexID.parseID("B"),gen.machine);

    LearnerGraph outcome = new LearnerGraph(gen.machine,Configuration.getDefaultConfiguration());
    Assert.assertEquals(2,outcome.getTransitionMatrix().get(outcome.findVertex(VertexID.parseID("A"))).size());
    Assert.assertTrue(gen.addEdgeInternal(vA, vB));// this adds a numeric label
View Full Code Here

  public void testAddEdgeFail1()
  {
    gen = new ForestFireLabelledStateMachineGenerator(0.3,0.2,0.2,0.1,0,0 ,config);
    gen.machine = FsmParser.buildGraph("A-0->B / A-1->C / A-2->D", "testAddEdgeFail2" ,config);
    gen.vertices = new LinkedList<DeterministicVertex>();gen.vertices.addAll(gen.machine.getVertices());
    final DeterministicVertex vA = (DeterministicVertex) DeterministicDirectedSparseGraph.findVertex(JUConstants.LABEL,VertexID.parseID("A"),gen.machine),
    vB = (DeterministicVertex) DeterministicDirectedSparseGraph.findVertex(JUConstants.LABEL,VertexID.parseID("B"),gen.machine);
   
    Assert.assertFalse(gen.addEdgeInternal(vA, vB));// this fails to add a label
  }
View Full Code Here

  public void testAddEdgeFail2()
  {
    gen = new ForestFireLabelledStateMachineGenerator(0.3,0.2,0.2,0.1,2,0 ,config);
    gen.machine = FsmParser.buildGraph("A-0->B / A-1->C / A-2->D", "testAddEdgeFail2" ,config);
    gen.vertices = new LinkedList<DeterministicVertex>();gen.vertices.addAll(gen.machine.getVertices());
    final DeterministicVertex vA = (DeterministicVertex) DeterministicDirectedSparseGraph.findVertex(JUConstants.LABEL,VertexID.parseID("A"),gen.machine),
    vB = (DeterministicVertex) DeterministicDirectedSparseGraph.findVertex(JUConstants.LABEL,VertexID.parseID("B"),gen.machine);
   
    Assert.assertFalse(gen.addEdgeInternal(vA, vB));// this fails to add a label
  }
View Full Code Here

  @Test
  public void testSelectVertices()
  {
    gen.machine = FsmParser.buildGraph("A-a->B-a->C\nA-b->B-c->C-a->D-a->E", "testRandomVertexSelection1" ,config);
    gen.vertices = new LinkedList<DeterministicVertex>();gen.vertices.addAll(gen.machine.getVertices());
    final DeterministicVertex
      vA = (DeterministicVertex) DeterministicDirectedSparseGraph.findVertex(JUConstants.LABEL,VertexID.parseID("A"),gen.machine),
      vB = (DeterministicVertex) DeterministicDirectedSparseGraph.findVertex(JUConstants.LABEL,VertexID.parseID("B"),gen.machine),
      vC = (DeterministicVertex) DeterministicDirectedSparseGraph.findVertex(JUConstants.LABEL,VertexID.parseID("C"),gen.machine),
      vD = (DeterministicVertex) DeterministicDirectedSparseGraph.findVertex(JUConstants.LABEL,VertexID.parseID("D"),gen.machine),
      vE = (DeterministicVertex) DeterministicDirectedSparseGraph.findVertex(JUConstants.LABEL,VertexID.parseID("E"),gen.machine);
View Full Code Here

  {
    synchronized(syncObj)
    {
      return conf.isLearnerUseStrings()?
          new StringVertex(name):
          new DeterministicVertex(name);     
    }   
  }
View Full Code Here

    visited = new HashSet<DeterministicVertex>();
    machine = new DirectedSparseGraph();
    vertices = new ArrayList<DeterministicVertex>();
    generator  = new MersenneTwister(seed);
    boolGenerator = new Random(seed);
    DeterministicVertex v=new DeterministicVertex(new VertexID(VertexID.VertKind.NEUTRAL,0));
    annotateVertex(v);
    machine.addVertex(v);
    vertices.add(v);// permits v to be chosen as a target, creating self-loops
    v.setUserDatum(JUConstants.INITIAL, true, UserData.SHARED);
  }
View Full Code Here

      int currentSize = 0;
      do
      {
        while(i < numberOfVerticesToAdd)
        {
          DeterministicVertex v=new DeterministicVertex(new VertexID(VertexID.VertKind.NEUTRAL,i+1));
          annotateVertex(v);
          machine.addVertex(v);
          vertices.add(v);// permits v to be chosen as a target, creating self-loops
          this.labelmap.put(v.getID(), v);
          Set<DeterministicVertex> tried = new TreeSet<DeterministicVertex>();
          tried.add(v);
          DeterministicVertex random = null;
          do
          {
            random = selectRandom(tried);
            tried.add(random);
          }
View Full Code Here

  protected DeterministicVertex selectRandom(Set<DeterministicVertex> blocked)
  {
    Set<DeterministicVertex> available = new TreeSet<DeterministicVertex>();available.addAll(vertices);
    if (blocked != null) available.removeAll(blocked);
    if (available.isEmpty()) throw new IllegalArgumentException("no vertices to select from");
    DeterministicVertex availableArray[] = new DeterministicVertex[available.size()];available.toArray(availableArray);
    return availableArray[randomInt(availableArray.length)];
  }
View Full Code Here

TOP

Related Classes of statechum.DeterministicDirectedSparseGraph.DeterministicVertex

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.