Package statechum.DeterministicDirectedSparseGraph

Examples of statechum.DeterministicDirectedSparseGraph.VertexID


    //Visualiser.updateFrame(g, null);
    LearnerGraph fsm = new LearnerGraph(g,config);
    Collection<Collection<CmpVertex>> result = new LinkedList<Collection<CmpVertex>>();
    int score = -2;
    //Visualiser.waitForKey();
    score = fsm.pairscores.computePairCompatibilityScore_general(new StatePair(fsm.findVertex(new VertexID("A")),fsm.findVertex(new VertexID("B"))),result);
    Assert.assertEquals(expectedScore, score);
    if (score >=0)
      matchCollectionsOfVertices(result, expectedSrc);
   
    result.clear();score = -2;
    score = fsm.pairscores.computePairCompatibilityScore_general(new StatePair(fsm.findVertex(new VertexID("A")),fsm.findVertex(new VertexID("B"))),result);
    Assert.assertEquals(expectedScore, score);
    if (score >=0)
      matchCollectionsOfVertices(result, expectedSrc);
  }
View Full Code Here


            throw new FatalException("Error parsing graph. Graph element must be specified before node element.");
        }

        String idString = (String) attributeMap.remove("id");
        DeterministicDirectedSparseGraph.DeterministicVertex vertex =
          new DeterministicDirectedSparseGraph.DeterministicVertex(new VertexID(idString));// this ID will be subsequently modified when we look at the "VERTEX" tag.
        mGraph.addVertex(vertex);

        try {
            mLabeller.setLabel((Vertex) vertex,idString);
        } catch (StringLabeller.UniqueLabelException ule) {
            throw new FatalException("Ids must be unique");

        }

        for (Iterator keyIt = attributeMap.keySet().iterator();keyIt.hasNext();)
        {
            Object key = keyIt.next();
            Object value = attributeMap.get(key);
           
            MiniPair p=new MiniPair(key,value);
            vertex.setUserDatum(p.getKey(), p.getValue(), UserData.SHARED);
        }
     
       String label = attributeMap.get("VERTEX").toString();
        if(label.startsWith(Transform.Initial))
        {
          vertex.addUserDatum("startOrTerminal", "start", UserData.SHARED);
          vertex.addUserDatum(JUConstants.INITIAL, true, UserData.SHARED);
          label = label.replaceAll(Transform.Initial+" *", "");
        }
       
         vertex.setUserDatum(JUConstants.LABEL, new VertexID(label), UserData.SHARED);
         if (!vertex.containsUserDatumKey(JUConstants.ACCEPTED))
           vertex.setUserDatum(JUConstants.ACCEPTED, true, UserData.SHARED);
       
        return vertex;
    }
View Full Code Here

    // will be included
    {
      LearnerGraph Plus = graph.copy(config);
      for(int i=0;i<1000;++i)
      {
        VertexID id = Plus.nextID(true);
        if (graph.findVertex(id) != null) return false;
      }
    }

    {
      LearnerGraph Minus = graph.copy(config);
      for(int i=0;i<1000;++i)
      {
        VertexID id = Minus.nextID(false);
        if (graph.findVertex(id) != null) return false;
      }
    }

    return true;
View Full Code Here

   * modifying the graph in the process. For graphs we'd rather not modify, this can be set to false, but then each call
   * will give the same identifier.
   */
  public synchronized VertexID nextID(JUConstants.VERTEXLABEL accepted, boolean store)
  {
    VertexID result = null;
    int positiveID = vertPositiveID, negativeID = vertNegativeID;
    if (config.getLearnerIdMode() == IDMode.POSITIVE_ONLY)
      result = new VertexID(VertKind.NEUTRAL,positiveID++);
    else
      result = (accepted != VERTEXLABEL.REJECT?new VertexID(VertKind.POSITIVE,positiveID++):
          new VertexID(VertKind.NEGATIVE,negativeID++));

    if (store)
    {
      vertPositiveID = positiveID;vertNegativeID = negativeID;
    }
View Full Code Here

  public synchronized VertexID getDefaultInitialPTAName()
  {
    if (config.getDefaultInitialPTAName().length() > 0)
      return VertexID.parseID(config.getDefaultInitialPTAName());
    return new VertexID(VertKind.POSITIVE,vertPositiveID++);
    // Since the text ID of the initial vertex is "Init" which does not contain numerical ID,
    // I cannot adequately load graphs containing such vertices. The best solution is to abolish it.
    //new VertexID(VertKind.INIT,vertPositiveID++);
  }
View Full Code Here

   * Important: do not change the acceptance condition on the returned vertex: it will mess up the
   * transition matrix since hash code is dependent on acceptance.
   */
  public CmpVertex findVertex(String name)
  {
    return findVertex(new VertexID(name));
  }
View Full Code Here

    CmpVertex result = null;
    Iterator<Entry<CmpVertex,Map<String,CmpVertex>>> entryIt = transitionMatrix.entrySet().iterator();
    while(entryIt.hasNext() && result == null)
    {
      CmpVertex currentVert = entryIt.next().getKey();
      VertexID vertName = currentVert.getID();
      if (vertName.equals(name))
        result = currentVert;
    }
    return result;
  }
View Full Code Here

  protected int vertNegativeID = 1000;

  /** Generates vertex IDs. Since it modifies instance ID-related variables, it has to be synchronized. */
  public synchronized VertexID nextID(boolean accepted)
  {
    VertexID result = null;
    if (config.getLearnerIdMode() == IDMode.POSITIVE_ONLY)
      result = new VertexID(VertKind.NEUTRAL,vertPositiveID++);
    else
      result = (accepted?new VertexID(VertKind.POSITIVE,vertPositiveID++):
          new VertexID(VertKind.NEGATIVE,vertNegativeID++));

    return result;
  }
View Full Code Here

  }

  public synchronized VertexID getDefaultInitialPTAName()
  {
    if (config.getDefaultInitialPTAName().length() > 0)
      return new VertexID(config.getDefaultInitialPTAName());
   
    // Since the numerical ID of the init vertex is not stored in XML, it is not possible to load it and
    // hence not feasible to replicate experiments using such vertex.
    return new VertexID(VertKind.POSITIVE,vertPositiveID++);//new VertexID(VertKind.INIT,vertPositiveID++);
  }
View Full Code Here

      Object label = srcVert.getUserDatum(JUConstants.LABEL);
      if (label instanceof VertexID)
        result = generateNewCmpVertex((VertexID)label, conf);
      else
        if (label instanceof String)
          result = generateNewCmpVertex(new VertexID((String)label), conf);
        else
          throw new IllegalArgumentException("vertex with label "+label+" has an unsupported type");// TODO: to test that this exception is thrown
      result.setAccept(DeterministicDirectedSparseGraph.isAccept(srcVert));
      if (srcVert.containsUserDatumKey(JUConstants.COLOUR))
        result.setColour((JUConstants)srcVert.getUserDatum(JUConstants.COLOUR));
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.