Package nz.ac.waikato.jdsl.graph.api

Examples of nz.ac.waikato.jdsl.graph.api.Edge$NONEEdge


    Assert.assertEquals("2", s2.element());
    // we must iterate through the edges, because graph.aConnectingEdge
    // does not respect the direction of the edge!
    EdgeIterator iter = graph.edges();
    while (iter.hasNext()) {
      Edge e = iter.nextEdge();
      if (graph.origin(e) == s2 && graph.destination(e) == s0)
        Assert.assertEquals("action0", e.element());
      else if (graph.origin(e) == s2 && graph.destination(e) == s1)
        Assert.assertEquals("action1", e.element());
      else if (graph.origin(e) == s0 && graph.destination(e) == s2)
        Assert.assertEquals("action2", e.element());
      else
        Assert.assertEquals("actionNone", e.element());
    }
  }
View Full Code Here


    assertEquals(3, listen.getVertexMap().size());
    // we must iterate through the edges, because graph.aConnectingEdge
    // does not respect the direction of the edge!
    EdgeIterator iter = graph.edges();
    while (iter.hasNext()) {
      Edge e = iter.nextEdge();
      if (graph.origin(e) == s2 && graph.destination(e) == s0)
        assertEquals("action0", e.element());
      else if (graph.origin(e) == s2 && graph.destination(e) == s1)
        assertEquals("action1", e.element());
      else if (graph.origin(e) == s0 && graph.destination(e) == s2)
        assertEquals("action2", e.element());
      else
        assertEquals("actionNone", e.element());
    }
  }
View Full Code Here

    shortName = shortName.substring(shortName.lastIndexOf('.')+1);
    output.println("digraph "+shortName);
    output.println("{");
    EdgeIterator edges = fsmGraph_.edges();
    while (edges.hasNext()) {
      Edge e = edges.nextEdge();
      Object origin = fsmGraph_.origin(e).element();
      Object dest = fsmGraph_.destination(e).element();
      String action = (String) e.element();
      output.println("  "+stateName(origin)+" -> "+stateName(dest)
          +"  [label=\""+action+"\"];");
    }
    output.println("}");
    output.close();
View Full Code Here

    // see if fsmGraph_ already contains this edge.
    boolean present = false;
    EdgeIterator edges = fsmGraph_.connectingEdges(oldVertex, newVertex);
    while (edges.hasNext()) {
      Edge edge = edges.nextEdge();
      if (edge.element().equals(actionName)
          && fsmGraph_.origin(edge) == oldVertex
          && fsmGraph_.destination(edge) == newVertex) {
        present = true;
        break;
      }
View Full Code Here

    }
    // see if fsmGraph already contains this edge.
    boolean present = false;
    EdgeIterator edges = fsmGraph.connectingEdges(oldVertex, newVertex);
    while (edges.hasNext()) {
      Edge edge = edges.nextEdge();
      if (edge.element().equals(actionName)
          && fsmGraph.origin(edge) == oldVertex
          && fsmGraph.destination(edge) == newVertex) {
        present = true;
        break;
      }
View Full Code Here

    shortName = shortName.substring(shortName.lastIndexOf('.')+1);
    output.println("digraph "+shortName);
    output.println("{");
    EdgeIterator edges = fsmGraph.edges();
    while (edges.hasNext()) {
      Edge e = edges.nextEdge();
      Object origin = fsmGraph.origin(e).element();
      Object dest = fsmGraph.destination(e).element();
      String action = (String) e.element();
      output.println("  "+stateName(origin)+" -> "+stateName(dest)
          +"  [label=\""+action+"\"];");
    }
    output.println("}");
    output.close();
View Full Code Here

    if (!finder.pathExists())
      return path;
    else {
      EdgeIterator itr = finder.reportPath();
      while (itr.hasNext()) {
        Edge e = itr.nextEdge();
        Object s = graph.origin(e).element();
        Object d = graph.destination(e).element();
        String action = (String) e.element();
        Transition trans = new Transition(s, action, d);
        path.add(trans);
      }
      return path;
    }
View Full Code Here

    EdgeIterator edges = fsmGraph.edges();

    // look ahead into the paths that we know about
    // TODO: iterate only over the nodes out of this state
    while (edges.hasNext()) {
      Edge e = edges.nextEdge();
      Object origin = fsmGraph.origin(e).element();
      Object dest = fsmGraph.destination(e).element();
      String actionName = (String) e.element();
      int actionNum = model_.getActionNumber(actionName);
      if (origin.equals(state)) {
        Transition tr = new Transition(origin, (String) e.element(), dest);
        Integer takenBefore = transitions_.getDetails().get(tr);
        if (takenBefore == null) {
          // This means that the transitions_ coverage is less accurate
          // than the graph_ coverage, probably because they were added
          // at different times.
View Full Code Here

    @Override
    public void setGraph(InspectableGraph model, Map<Object, Vertex> state2vertex) {
        // TODO: this will not be needed once model_ is never null.

        for (EdgeIterator iter = model.edges(); iter.hasNext();) {
            Edge e = iter.nextEdge();
            addItem(e.element()); // get the FSM state object.
        }
        maxCoverage_ = coverage_.size();
    }
View Full Code Here

        EdgeIterator graphEdges = graph.getGraph().edges();
        VertexInfo src;
        VertexInfo dest;
        seenFirstState = false;
        while (graphEdges.hasNext()) {
            Edge e = graphEdges.nextEdge();
            if (!vertices.containsKey(graph.getGraph().origin(e).element())) {
                src = new VertexInfo(graph.getGraph().origin(e).element());
            } else {
                src = (VertexInfo) vertices.get(graph.getGraph().origin(e).element());
            }
            g.addVertex(src);
            if (!seenFirstState) {
                src.setStartState(true);
                seenFirstState = true;
            }
            vertices.put(src.getName(), src);

            if (!vertices.containsKey(graph.getGraph().destination(e).element())) {
                dest = new VertexInfo(graph.getGraph().destination(e).element());
            } else {
                dest = (VertexInfo) vertices.get(graph.getGraph().destination(e).element());
            }
            g.addVertex(dest);
            vertices.put(dest.getName(), dest);

            Transition action = new Transition(src.getName(), (String) e.element(), dest.getName());
            EdgeInfo edge = new EdgeInfo(action, src, dest);
            g.addEdge(edge, src, dest);
            edges.put(action, edge);

            edge.getSrcVertex().setOutgoingEdges(edge.getSrcVertex().getOutgoingEdges() + 1);
View Full Code Here

TOP

Related Classes of nz.ac.waikato.jdsl.graph.api.Edge$NONEEdge

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.