Examples of DirectedSparseGraph


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

 
  @Test(expected = IllegalArgumentException.class)
  public final void testMerge_fail1a()
  {
    DirectedSparseGraph g=FsmParser.buildGraph(largeGraph1_invalid5,"testMerge_fail1");
    CmpVertex
      a = DeterministicDirectedSparseGraph.findVertexNamed(new VertexID("A"), g),
      b = DeterministicDirectedSparseGraph.findVertexNamed(new VertexID("B"), g);
    StatePair pair = new StatePair(b,a);// A is red
    MergeStates.mergeAndDeterminize(g, pair,testConfig);
View Full Code Here

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 = FsmParser.buildGraph(fsm, graphName);
    //Visualiser.updateFrame(new LearnerGraph(gB,Configuration.getDefaultConfiguration()), null);Visualiser.waitForKey();
    // check how the reference pair selection function performs
    Configuration conf = testConfig.copy();conf.setLearnerUseStrings(false);conf.setLearnerCloneGraph(false);
    testChooseStatePairsInternal(gB,new LearnerGraph(gB, conf), initialReds, expectedReds, expectedPairs, new InterfaceChooserToTest() {
      public @Override 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 = FsmParser.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 @Override Stack<? extends StatePair> choosePairs() {
        return s.pairscores.chooseStatePairs();
View Full Code Here

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

    {
      Set<String> possibleReds = new HashSet<String>();possibleReds.addAll(Arrays.asList(expectedReds[i]));
      expectedRedsAsSet.add(possibleReds);
    }
    Set<String> finalReds = new HashSet<String>();
    DirectedSparseGraph grf = l.pathroutines.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

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

      int k1,int k2,int k3,
      String graphName)
  {
    //buildRubyTests(fsm,expectedComputedScore,graphName);
   
    DirectedSparseGraph g = FsmParser.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

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

  }
 
  private void testGeneralPairScoreComputation(String machine, String graphName, int expectedScore,
      String[][] expectedSrc,String [][]incompatibles)
  {
    DirectedSparseGraph g=FsmParser.buildGraph(machine, graphName);
    LearnerGraph fsm = new LearnerGraph(g,config);

    if (incompatibles != null)
      for(String [] incompatibleRow:incompatibles)
      {
View Full Code Here

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

                        if (command.equals(msgTestDiffParsing) && message.arity() == 4) // this one computes a graph reflecting the differences and returns the labelling part of it as a string. Inputs are one of the original machines and the differences.
                        {
                          OtpErlangObject outcome = null;
                          try
                          {
                            DirectedSparseGraph diff = DifferenceVisualiser.ChangesToGraph.computeVisualisationParameters(message.elementAt(2), message.elementAt(3));
                           
                            Set<String> modifiedLines = new TreeSet<String>();
                            for(Object obj:diff.getEdges()) // getEdges returns edges in a JDK-dependent order, we use TreeSet to sort them so that expected values can be determined without associating them with specific versions of JDK.
                            {
                              StringBuffer textOfTheOutcome = new StringBuffer();
                             
                              textOfTheOutcome.append(obj.toString());textOfTheOutcome.append(":");textOfTheOutcome.append( ((Edge)obj).getUserDatum(JUConstants.DIFF) );
                              modifiedLines.add(textOfTheOutcome.toString());
                            }
                            outcome = new OtpErlangTuple(new OtpErlangObject[]{ref,msgOk,new OtpErlangAtom(modifiedLines.toString())});
                          }
                          catch(Throwable ex)
                          {
                            outcome = new OtpErlangTuple(new OtpErlangObject[]{ref,msgFailure,new OtpErlangList(ex.getMessage())});
                          }
                          mbox.send(erlangPartner,outcome);
                        }
                        else
                         
                        // Arguments: Ref, 'displayDiff', first graph, diff, atom with the name of the difference and (optional) list of states (as atoms) to ignore.
                        // Upon error, no notifications are sent and instead an error is reported.
                        // Note: if the difference name is an empty sequence, no graph is displayed but notifications are provided (for testing).
                        if (command.equals(msgDisplayDiff) && message.arity() >= 5)
                        {
                          OtpErlangObject outcome = null;
                          try
                          {
                            DirectedSparseGraph diff = DifferenceVisualiser.ChangesToGraph.computeVisualisationParameters(message.elementAt(2), message.elementAt(3));
                            int windowNumber = setOptions(message,4,diff);
                            if (windowNumber >= 0)
                              Visualiser.updateFrameWithPos(diff,windowNumber);

                            outcome = new OtpErlangTuple(new OtpErlangObject[]{ref,msgOk});
                          }
                          catch(Throwable ex)
                          {
                            outcome = new OtpErlangTuple(new OtpErlangObject[]{ref,msgFailure,new OtpErlangList(ex.getMessage())});
                          }
                          mbox.send(erlangPartner,outcome);
                        }
                        else
                          // Arguments: Ref, 'displayFSM', graph, atom with the name of the difference and (optional) list of states (as atoms) to ignore.
                          // Upon error, no notifications are sent and instead an error is reported.
                          // Note: if the difference name is an empty sequence, no graph is displayed but notifications are provided (for testing).
                          if (command.equals(msgDisplayFSM) && message.arity() >= 4)
                          {
                            OtpErlangObject outcome = null;
                            try
                            {
                              Configuration config = Configuration.getDefaultConfiguration().copy();
                              LearnerGraphND machine = new LearnerGraphND(config);Synapse.StatechumProcess.parseStatemachine(message.elementAt(2),machine,null,true);
                              DirectedSparseGraph fsmPicture = machine.pathroutines.getGraph();
                              if (!fsmPicture.containsUserDatumKey(JUConstants.LAYOUTOPTIONS))
                                fsmPicture.addUserDatum(JUConstants.LAYOUTOPTIONS,new LayoutOptions(), UserData.SHARED);
                              int windowNumber = setOptions(message,3,fsmPicture);
                              if (windowNumber >= 0)
                                Visualiser.updateFrameWithPos(fsmPicture,windowNumber);

                              outcome = new OtpErlangTuple(new OtpErlangObject[]{ref,msgOk});
View Full Code Here

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

  public static DirectedSparseGraph mergeAndDeterminize(Graph model, OrigStatePair pair){
    Graph original = (Graph)model.copy();
    Vertex q = DeterministicDirectedSparseGraph.findVertex(JUConstants.LABEL, pair.getQ().getUserDatum(JUConstants.LABEL),original);
    Vertex qDash = DeterministicDirectedSparseGraph.findVertex(JUConstants.LABEL, pair.getR().getUserDatum(JUConstants.LABEL),original);
    pair = new OrigStatePair(q,qDash);
    DirectedSparseGraph temp = merge((DirectedSparseGraph)original, pair);
    OrigStatePair mergable = findMergablePair(temp);
    while(mergable!=null){
      temp=merge(temp, mergable);
      mergable = findMergablePair(temp);
    }
View Full Code Here

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

    Stack<OrigStatePair> possibleMerges = chooseStatePairs(model, sPlus, sMinus);
    while(!possibleMerges.isEmpty()){
      OrigStatePair pair = possibleMerges.pop();

      DirectedSparseGraph temp = mergeAndDeterminize((Graph)model.copy(), pair);
      if(compatible(temp, sPlus, sMinus)){// KIRR: the should always return true
        pair.getQ().setUserDatum(JUConstants.HIGHLIGHT, pair, UserData.SHARED);
        pair.getR().setUserDatum(JUConstants.HIGHLIGHT, pair, UserData.SHARED);
        setChanged();
        List<List<String>> questions;
View Full Code Here

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

    @Override
    public void update(@SuppressWarnings("unused") final Observable s, Object arg) {
        if (arg instanceof AbstractLearnerGraph) {
            graphs.add(((AbstractLearnerGraph) arg).pathroutines.getGraph());layoutOptions.add(new LayoutOptions());
        } else if (arg instanceof DirectedSparseGraph) {
          DirectedSparseGraph gr = (DirectedSparseGraph) arg;
            graphs.add(gr);layoutOptions.add((LayoutOptions)gr.getUserDatum(JUConstants.LAYOUTOPTIONS));
        } else {
            System.err.println("Visualiser notified with unknown object " + arg);
        }
       
        currentGraph = graphs.size() - 1;
View Full Code Here

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

      while(!redStack.isEmpty()){
        Vertex redVertex = redStack.pop();
        OrigStatePair pair = new OrigStatePair(blueVertex, redVertex);
        doneEdges = new HashSet<DirectedSparseEdge>();
        Integer score = new Integer(computeScore(g,pair));
        DirectedSparseGraph temp = mergeAndDeterminize((Graph)g.copy(), pair);
        if(compatible(temp, sPlus, sMinus)){
          // singleSet maps scores to pairs which have those scores
          if(score<config.getKlimit())
            continue;
          if(singleSet.get(score) == null){
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.