Package edu.uci.ics.jung.graph.impl

Examples of edu.uci.ics.jung.graph.impl.DirectedSparseGraph


   * @param expectedPairs a set of pairs which has to be returned
   * @param graphName the name to give to the constructed graph
   */
  public final void testChooseStatePairs(String fsm, String [] initialReds, String [][] expectedReds, List<PairScore> expectedPairs, String graphName)
  {
    final DirectedSparseGraph gB = TestFSMAlgo.buildGraph(fsm, graphName);
    // check how the reference pair selection function performs
    Configuration conf = (Configuration)testConfig.clone();conf.setLearnerUseStrings(false);conf.setLearnerCloneGraph(false);
    testChooseStatePairsInternal(gB,new LearnerGraph(gB, conf), initialReds, expectedReds, expectedPairs, new InterfaceChooserToTest() {
      public Stack<StatePair> choosePairs() {// Here I need to convert the old type of pairs to the new one.
        Stack<OrigStatePair> pairs = chooseStatePairs(gB, new HashSet<List<String>>(), new HashSet<List<String>>());
        Stack<StatePair> result = new Stack<StatePair>();
        for(OrigStatePair pair:pairs) result.add(new StatePair((CmpVertex)pair.getQ(),(CmpVertex)pair.getR()));
        return result;
      }
    });

    final DirectedSparseGraph gA = TestFSMAlgo.buildGraph(fsm, graphName);
    // check how the revised pair selection function performs
    final LearnerGraph s = new LearnerGraph(gA, testConfig);
    testChooseStatePairsInternal(gA,s, initialReds, expectedReds, expectedPairs, new InterfaceChooserToTest() {
      public Stack<? extends StatePair> choosePairs() {
        return s.pairscores.chooseStatePairs();
View Full Code Here


    {
      Set<String> possibleReds = new HashSet<String>();possibleReds.addAll(Arrays.asList(expectedReds[i]));
      expectedRedsAsSet.add(possibleReds);
    }
    Set<String> finalReds = new HashSet<String>();
    DirectedSparseGraph grf = l.paths.getGraph();
    for(Vertex red:DeterministicDirectedSparseGraph.findVertices(JUConstants.COLOUR, JUConstants.RED, grf))
        finalReds.add(((VertexID)red.getUserDatum(JUConstants.LABEL)).toString());
    Assert.assertTrue("expected red states, any of: "+expectedRedsAsSet+" actual : "+finalReds,expectedRedsAsSet.contains(finalReds));
    for(PairScore ps:expectedPairs)
    {
View Full Code Here

      int expectedComputedScore,int pairCompatibilityScore,
      int pairCompatibility,
      int k1,int k2,int k3,
      String graphName)
  {
    DirectedSparseGraph g = TestFSMAlgo.buildGraph(fsm, graphName);
    OrigStatePair pairOrig = new OrigStatePair(
        DeterministicDirectedSparseGraph.findVertex(JUConstants.LABEL, new VertexID("B"), g),
        DeterministicDirectedSparseGraph.findVertex(JUConstants.LABEL, new VertexID("A"), g));
   
    LearnerGraph s = new LearnerGraph(g, testConfig);
View Full Code Here

  }
 
  private void testGeneralPairScoreComputation(String machine, String graphName, int expectedScore,
      String[][] expectedSrc)
  {
    DirectedSparseGraph g=TestFSMAlgo.buildGraph(machine, graphName);
    //Visualiser.updateFrame(g, null);
    LearnerGraph fsm = new LearnerGraph(g,config);
    Collection<Collection<CmpVertex>> result = new LinkedList<Collection<CmpVertex>>();
    int score = -2;
    //Visualiser.waitForKey();
View Full Code Here

{
  @Test
  public void testAugmentPTA() // only two traces, both accept
  {
    Set<List<String>> plusStrings = buildSet(new String[][] { new String[] {"a","b","c"},new String[]{"a","d","c"} });
    DirectedSparseGraph actualA = new RPNIBlueFringeLearnerOrig(null,Configuration.getDefaultConfiguration()).augmentPTA(DeterministicDirectedSparseGraph.initialise(), plusStrings, true),
      actualC = null;
    DeterministicDirectedSparseGraph.numberVertices(actualA);// Numbering is necessary to ensure uniqueness of labels used by LearnerGraph constructor.
    Configuration config = (Configuration)Configuration.getDefaultConfiguration().clone();config.setLearnerIdMode(Configuration.IDMode.POSITIVE_NEGATIVE);
    config.setAllowedToCloneNonCmpVertex(true);
    LearnerGraph l = new LearnerGraph(config);
View Full Code Here

  }
 
  private void checkEmptyPTA(String[][] arrayPlusStrings,String [][] arrayMinusStrings)
  {
    Set<List<String>> plusStrings = buildSet(arrayPlusStrings), minusStrings = buildSet(arrayMinusStrings);
    DirectedSparseGraph actualA = null, actualC = null, actualD = null, actualE = null;
    IllegalArgumentException eA = null, eC = null, eD = null, eE = null;
    try
    {
      actualA = new RPNIBlueFringeLearnerOrig(null,Configuration.getDefaultConfiguration()).createAugmentedPTA(DeterministicDirectedSparseGraph.initialise(), plusStrings, minusStrings);
    }
    catch(IllegalArgumentException e)
    {
      // ignore this - it might be expected.
      eA = e;
    }

    try
    {
      Configuration config = (Configuration)Configuration.getDefaultConfiguration().clone();
      RPNIBlueFringeLearnerTestComponentOpt l = new RPNIBlueFringeLearnerTestComponentOpt(null,config);
      config.setLearnerIdMode(Configuration.IDMode.POSITIVE_NEGATIVE);
      l.init(plusStrings, minusStrings);
      actualC = l.scoreComputer.paths.getGraph();
    }
    catch(IllegalArgumentException e)
    {
      // ignore this - it might be expected.
      eC = e;
    }

    try
    {
      Configuration config = (Configuration)Configuration.getDefaultConfiguration().clone();
      RPNIBlueFringeLearnerTestComponentOpt l = new RPNIBlueFringeLearnerTestComponentOpt(null,config);
      config.setLearnerIdMode(Configuration.IDMode.POSITIVE_NEGATIVE);
      PTASequenceEngine engine = buildPTA(plusStrings, minusStrings);
      checkPTAConsistency(engine, plusStrings, true);if (engine.numberOfLeafNodes()>0) checkPTAConsistency(engine, minusStrings, false);
      l.init(engine,0,0);
      actualD = l.scoreComputer.paths.getGraph();
    }
    catch(IllegalArgumentException e)
    {
      // ignore this - it might be expected.
      eD = e;
    }

    try
    {
      Configuration config = (Configuration)Configuration.getDefaultConfiguration().clone();
      RPNIBlueFringeLearnerTestComponentOpt l = new RPNIBlueFringeLearnerTestComponentOpt(null,config);
      config.setLearnerIdMode(Configuration.IDMode.POSITIVE_NEGATIVE);
      l.init(buildPTA(plusStrings, buildSet(new String[][] {})),0,0);
      for(List<String> seq:minusStrings)
        l.scoreComputer.paths.augmentPTA(buildPTA(buildSet(new String[][] {}),buildSet(new String[][] { (String [])seq.toArray()})));
      actualE = l.scoreComputer.paths.getGraph();
    }
    catch(IllegalArgumentException e)
    {
      // ignore this - it might be expected.
      eE = e;
    }

    if (eA != null)
    {
      Assert.assertNotNull(eC);
      Assert.assertNotNull(eD);
      Assert.assertNotNull(eE);
      throw eA;
    }
   
    Assert.assertNull(eA);
    Assert.assertNull(eC);
    Assert.assertNull(eD);
    Assert.assertNull(eE);
       
    Assert.assertEquals(1, actualA.getVertices().size());Assert.assertEquals(true, DeterministicDirectedSparseGraph.isAccept( ((Vertex)actualA.getVertices().iterator().next()) ));
    Assert.assertEquals(0, actualA.getEdges().size());

    Assert.assertEquals(1, actualC.getVertices().size());Assert.assertEquals(true, DeterministicDirectedSparseGraph.isAccept( ((Vertex)actualC.getVertices().iterator().next()) ));
    Assert.assertEquals(0, actualC.getEdges().size());

    Assert.assertEquals(1, actualD.getVertices().size());Assert.assertEquals(true, DeterministicDirectedSparseGraph.isAccept( ((Vertex)actualD.getVertices().iterator().next()) ));
View Full Code Here

   * @param expectedPTA a textual representation of a PTA which should be built.
   */
  private void checkPTAconstruction(String[][] arrayPlusStrings,String [][] arrayMinusStrings, String expectedPTA)
  {
    Set<List<String>> plusStrings = buildSet(arrayPlusStrings), minusStrings = buildSet(arrayMinusStrings);
    DirectedSparseGraph actualA = null, actualC =null, actualD = null, actualE = null;
    IllegalArgumentException eA = null, eC = null, eD = null, eE = null;
    try
    {
      actualA = new RPNIBlueFringeLearnerOrig(null, Configuration.getDefaultConfiguration()).createAugmentedPTA(DeterministicDirectedSparseGraph.initialise(), plusStrings, minusStrings);
    }
View Full Code Here

    setChanged();

    Stack<OrigStatePair> possibleMerges = chooseStatePairs(model, sPlus, sMinus);
    while(!possibleMerges.isEmpty()){
      OrigStatePair pair = possibleMerges.pop();
      DirectedSparseGraph temp = mergeAndDeterminize(model, pair);
      pair.getQ().setUserDatum(JUConstants.HIGHLIGHT, pair, UserData.SHARED);
      pair.getR().setUserDatum(JUConstants.HIGHLIGHT, pair, UserData.SHARED);// since this copy of the graph will really not be used, changes to it are immaterial at this stage
      setChanged();
      List<List<String>> questions = new ArrayList<List<String>>();
      doneEdges = new HashSet<DirectedSparseEdge>();
View Full Code Here

    if(loopEdge!=null){
      Collection<String> looplabels = (Collection<String>)loopEdge.getUserDatum(JUConstants.LABEL);
      questions.addAll(mergePrefixWithSuffixes(prefixes, looplabels,suffixes));
    }
   
    DirectedSparseGraph questionPrefixes = augmentPTA(DeterministicDirectedSparseGraph.initialise(), questions, true);
    Iterator<Vertex> questionIt = getEndPoints(questionPrefixes).iterator();
    p = new DijkstraShortestPath(questionPrefixes);
    questions =new ArrayList<List<String>>();
    Vertex init = DeterministicDirectedSparseGraph.findInitial(questionPrefixes);
    while(questionIt.hasNext()){
View Full Code Here

    File graphDir = new File(args[0]);//new File(System.getProperty("user.dir")+System.getProperty("file.separator")+"resources"+
    //System.getProperty("file.separator")+"TestGraphs"+System.getProperty("file.separator") +args[0]);
    String wholePath = graphDir.getAbsolutePath()+System.getProperty("file.separator");
    GraphMLFile graphmlFile = new GraphMLFile();
    graphmlFile.setGraphMLFileHandler(new ExperimentGraphMLHandler());
    DirectedSparseGraph dg = new DirectedSparseGraph();
    dg.getEdgeConstraints().clear();
    dg = (DirectedSparseGraph)graphmlFile.load(wholePath+args[1]);
    GraphMLVisualiser gmlVis = new GraphMLVisualiser();
    gmlVis.construct(dg);
  }
View Full Code Here

TOP

Related Classes of edu.uci.ics.jung.graph.impl.DirectedSparseGraph

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.