Package edu.uci.ics.jung.graph

Examples of edu.uci.ics.jung.graph.Vertex


      HashSet<String> labels = (HashSet<String>)e.getUserDatum(JUConstants.LABEL);
      Iterator<String> labelIt = labels.iterator();
      while(labelIt.hasNext()){
        List<String> string = new ArrayList<String>();
        string.add(labelIt.next());
        Vertex qi = e.getDest();
        Vertex qj = getVertex(original,blueRed.getR(), string);
        OrigStatePair newPair = new OrigStatePair(qi, qj);
        if(qj!=null){
          int equivalent = computeScore(original, newPair);
          if(equivalent<0){
            return -1;
View Full Code Here


      if (string.isEmpty() && !accepted)
        throw new IllegalArgumentException("since the initial state is an accept one, a negative string should not be empty");
     
      for(int i = 1;i<=string.size();i++){
        List<String> current = string.subList(0, i);
        Vertex existing = getVertex(pta,current);

        Vertex newVertex = new DirectedSparseVertex();
        if (i == string.size())// KIRR: every prefix of a reject sequence is an accept sequence.
          newVertex.setUserDatum(JUConstants.ACCEPTED, accepted, UserData.SHARED);
        else
          newVertex.setUserDatum(JUConstants.ACCEPTED, true, UserData.SHARED);
       
        if(existing == null){
          pta.addVertex(newVertex);
          Vertex previous;
          previous = getVertex(pta, string.subList(0, i-1));// for i==1, getVertex will return the initial vertex
          DirectedSparseEdge e = new DirectedSparseEdge(previous, newVertex);
          Set<String> labels = new HashSet<String>();
          labels.add(string.get(i-1));
          e.addUserDatum(JUConstants.LABEL, labels, UserData.CLONE);
View Full Code Here

    }
    return pta;
  }
 
  protected static Vertex getVertex (@SuppressWarnings("unused") DirectedSparseGraph g,Vertex v, List<String> string){
    Vertex current = v;
    if (current == null)
      return null;
   
    for(int i = 0;i<string.size();i++){
      String label = string.get(i);
      DirectedSparseEdge edge = getEdgeWithLabel(current.getOutEdges(), label);
      if(edge == null)
        return null;
      current = edge.getDest();
    }
    return current;
View Full Code Here

  @SuppressWarnings("unchecked")
  private static Vertex getTempRed_DijkstraShortestPath(DirectedSparseGraph model, Vertex r, DirectedSparseGraph temp)
  {
    DijkstraShortestPath p = new DijkstraShortestPath(model);
    List<Edge> pathToRed = p.getPath(DeterministicDirectedSparseGraph.findInitial(model), r);
    Vertex tempRed = null;
    if(!pathToRed.isEmpty()){
      List<Label> pathToRedString = new LinkedList<Label>();
      for(Edge e:pathToRed)
        pathToRedString.add( ((Collection<Label>)e.getUserDatum(JUConstants.LABEL)).iterator().next() );
      tempRed = Test_Orig_RPNIBlueFringeLearner.getVertex(temp, pathToRedString);
View Full Code Here

  @Test
  public final void testGetTempRed1()
  {
    DirectedSparseGraph a=FsmParser.buildLearnerGraph("A-a->B", "testGetTempRed1 model",config,getLabelConverter()).pathroutines.getGraph(),
      temp=FsmParser.buildLearnerGraph("C-d->Q", "testGetTempRed1 temp",config,getLabelConverter()).pathroutines.getGraph();
    Vertex foundA = getTempRed_DijkstraShortestPath(a, DeterministicDirectedSparseGraph.findInitial(a), temp);
    Vertex foundB =Test_Orig_RPNIBlueFringeLearnerTestComponent.getTempRed(a, DeterministicDirectedSparseGraph.findInitial(a), temp);
    Assert.assertTrue(DeterministicDirectedSparseGraph.findInitial(temp).equals(foundA));
    Assert.assertTrue(DeterministicDirectedSparseGraph.findInitial(temp).equals(foundB));
  }
View Full Code Here

  @Test
  public final void testGetTempRed2()
  {
    DirectedSparseGraph a=FsmParser.buildLearnerGraph("A-a->B-a->B-c->C-c->D", "testGetTempRed1 model",config,getLabelConverter()).pathroutines.getGraph(),
      temp=FsmParser.buildLearnerGraph("C-a->Q-a->Q-c->Q", "testGetTempRed1 temp",config,getLabelConverter()).pathroutines.getGraph();
    Vertex foundA = getTempRed_DijkstraShortestPath(a, DeterministicDirectedSparseGraph.findVertex(JUConstants.LABEL, VertexID.parseID("D"), a), temp);
    Vertex foundB = Test_Orig_RPNIBlueFringeLearnerTestComponent.getTempRed(a, DeterministicDirectedSparseGraph.findVertex(JUConstants.LABEL, VertexID.parseID("D"), a), temp);
    Assert.assertTrue(DeterministicDirectedSparseGraph.findVertex(JUConstants.LABEL, VertexID.parseID("Q"), temp).equals(foundA));
    Assert.assertTrue(DeterministicDirectedSparseGraph.findVertex(JUConstants.LABEL, VertexID.parseID("Q"), temp).equals(foundB));
  }
View Full Code Here

 
  @Test
  public final void findMergeablePair2()
  {
    DirectedSparseGraph g=FsmParser.buildLearnerGraphND("A-a->B\nA-b->B\nA-c->D\nA-b->D\nA-d->E", "findMergeablePair2",config,getLabelConverter()).pathroutines.getGraph();
    Vertex
      b = DeterministicDirectedSparseGraph.findVertex(JUConstants.LABEL, VertexID.parseID("B"), g),
      d = DeterministicDirectedSparseGraph.findVertex(JUConstants.LABEL, VertexID.parseID("D"), g);
    Set<Vertex> expected = new HashSet<Vertex>();expected.add(d);expected.add(b);
    Set<Vertex> actualA = new HashSet<Vertex>();
    OrigStatePair value = Test_Orig_RPNIBlueFringeLearner.findMergablePair(g);actualA.add(value.getQ());actualA.add(value.getR());
View Full Code Here

 
  @Test
  public final void findMergeablePair3a()
  {
    DirectedSparseGraph g=FsmParser.buildLearnerGraphND("S-p->A-a->S\nA-b->S\nA-c->D\nA-b->D\nA-d->E", "findMergeablePair3a",config,getLabelConverter()).pathroutines.getGraph();
    Vertex
      s = DeterministicDirectedSparseGraph.findVertex(JUConstants.LABEL, VertexID.parseID("S"), g),
      d = DeterministicDirectedSparseGraph.findVertex(JUConstants.LABEL, VertexID.parseID("D"), g);
    OrigStatePair expected = new OrigStatePair(d,s),
    actualA = Test_Orig_RPNIBlueFringeLearner.findMergablePair(g);
    Assert.assertTrue("expected: "+expected+" got: "+actualA,expected.equals(actualA));
View Full Code Here

  @Test
  public final void findMergeablePair3b()
  {
    DirectedSparseGraph g=FsmParser.buildLearnerGraphND("S-p->A-a->B\nA-b->B\nA-c->S\nA-b->S\nA-d->E", "findMergeablePair3b",config,getLabelConverter()).pathroutines.getGraph();
    Vertex
      b = DeterministicDirectedSparseGraph.findVertex(JUConstants.LABEL, VertexID.parseID("B"), g),
      s = DeterministicDirectedSparseGraph.findVertex(JUConstants.LABEL, VertexID.parseID("S"), g);
    OrigStatePair expected = new OrigStatePair(b,s),
    actualA = Test_Orig_RPNIBlueFringeLearner.findMergablePair(g);
    Assert.assertTrue("expected: "+expected+" got: "+actualA,expected.equals(actualA));
View Full Code Here

  public void checkCorrectnessOfMerging(String machineToMerge, String expectedFSM,
      String stateBlue, String stateRed, String graphName, boolean checkWithEquals)
  {
    DirectedSparseGraph g=FsmParser.buildLearnerGraph(machineToMerge, graphName,config,getLabelConverter()).pathroutines.getGraph(),
      g2=(DirectedSparseGraph)g.copy();
    Vertex
      a = DeterministicDirectedSparseGraph.findVertex(JUConstants.LABEL, VertexID.parseID(stateRed), g),
      b = DeterministicDirectedSparseGraph.findVertex(JUConstants.LABEL, VertexID.parseID(stateBlue), g);
       
    Assert.assertNotNull("state "+stateRed+" was not found", a);
    Assert.assertNotNull("state "+stateBlue+" was not found", b);
View Full Code Here

TOP

Related Classes of edu.uci.ics.jung.graph.Vertex

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.