dk.brics.bisimulationGame.model
Class GrappaModel

java.lang.Object
  extended by dk.brics.bisimulationGame.model.GrappaModel

public class GrappaModel
extends java.lang.Object

A local data model holding a Grappa graph.

Author:
Martin Mosegaard martinm@daimi.au.dk

Field Summary
private  att.grappa.Node currentNode
           
private  att.grappa.Graph graph
           
private  java.lang.String initialNodeName
           
private  java.util.HashMap<att.grappa.Node,java.util.Vector<Successor>> successorMap
           
private  att.grappa.Node toNode
           
 
Constructor Summary
GrappaModel(java.lang.String initialNodeName)
          Constructs a Grappa model given the name of the initial node in the graph.
 
Method Summary
 att.grappa.Node getCurrentNode()
           
 java.lang.String getEdgeAction(att.grappa.Edge edge)
          Called when an edge has been clicked by the attacker.
private  java.util.Vector<java.lang.String> getEdgeLabels(java.util.Vector<Successor> toMap, att.grappa.Node to)
          Get the labels of in-edges of node 'to'.
 att.grappa.Graph getGraph()
           
 att.grappa.Node getInitialNode()
           
 boolean getMatchingEdgeAction(att.grappa.Edge edge, java.lang.String otherAction)
          Called when an edge has been clicked by the defender.
 boolean getMatchingNodeAction(att.grappa.Node node, java.lang.String attackersAction)
          Called when a node has been clicked by the defender.
 int getNumberOfStrongChoices()
          Return the number of outgoing edges from the current node.
 java.util.Vector<Successor> getStrongChoices()
          Used by an attacker to get all choices from the current node that are not weak.
private  java.util.HashMap<att.grappa.Node,java.util.Vector<Successor>> getStrongSuccessorMap()
          Makes a map from each node to its direct successors.
 java.util.HashMap<att.grappa.Node,java.util.Vector<Successor>> getSuccessorMap()
           
 java.lang.String getUniqueNodeAction(att.grappa.Node node)
          Called when a node has been clicked by the attacker.
private  java.util.HashMap<att.grappa.Node,java.util.Vector<Successor>> getWeakSuccessorMap()
          Makes a map from each node to its weak successors.
 boolean isActionEnabled(java.lang.String action)
          Check to see if there exists an outgoing edge from current node that has label = action.
private  void layoutGraph(java.lang.String dotPath)
          Attempts to layout a graph using the Graphviz dot program.
 boolean makeGrappaPanelFromGraph(java.lang.String dot, java.lang.String dotPath, int bisimulation)
          First construct a dot graph, then pass it to Grappa and try to make a Graph.
 boolean noActionEnabled()
           
 void reset()
          Reset the displayed automaton to its initial state.
private  void step()
           
 void stepTo(java.lang.String nodeName)
          Step to a given node in the graph.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

graph

private att.grappa.Graph graph

currentNode

private att.grappa.Node currentNode

toNode

private att.grappa.Node toNode

initialNodeName

private java.lang.String initialNodeName

successorMap

private java.util.HashMap<att.grappa.Node,java.util.Vector<Successor>> successorMap
Constructor Detail

GrappaModel

public GrappaModel(java.lang.String initialNodeName)
Constructs a Grappa model given the name of the initial node in the graph.

Parameters:
initialNodeName - The name of the initial node
Method Detail

makeGrappaPanelFromGraph

public boolean makeGrappaPanelFromGraph(java.lang.String dot,
                                        java.lang.String dotPath,
                                        int bisimulation)
First construct a dot graph, then pass it to Grappa and try to make a Graph.

Parameters:
dot - String representation of a dot-file
dotPath - Path to dot program
bisimulation - Bisimulation type, used for creating a successor map
Returns:
true if the graph has node elements

layoutGraph

private void layoutGraph(java.lang.String dotPath)
Attempts to layout a graph using the Graphviz dot program.

Parameters:
dotPath - Path to the dot executable

getGraph

public att.grappa.Graph getGraph()
Returns:
The Grappa graph

getCurrentNode

public att.grappa.Node getCurrentNode()
Returns:
The current node

getEdgeAction

public java.lang.String getEdgeAction(att.grappa.Edge edge)
Called when an edge has been clicked by the attacker. Sets up toNode and returns action name.

Parameters:
edge - Edge that has been mouse-clicked
Returns:
The action name of the edge.

getMatchingEdgeAction

public boolean getMatchingEdgeAction(att.grappa.Edge edge,
                                     java.lang.String otherAction)
Called when an edge has been clicked by the defender. Sets up toNode and returns action name. The edge action must match, even in the case of weak bisimulation.

Parameters:
edge - Edge that has been mouse-clicked
otherAction - Other action that must be matched
Returns:
True if the clicked edge has same name as otherAction

getUniqueNodeAction

public java.lang.String getUniqueNodeAction(att.grappa.Node node)
Called when a node has been clicked by the attacker. If the node has a unique edge from the current node, toNode is set up, and the action name of that edge is returned. The successor map cannot be used here, since in the case of a weak bisimulation, a node will always have a tau self-loop, which is only eligible for a defender, however.

Parameters:
node - The node clicked.
Returns:
The name of the action of the unique edge between current node and clicked, or null if it does not exist.

getMatchingNodeAction

public boolean getMatchingNodeAction(att.grappa.Node node,
                                     java.lang.String attackersAction)
Called when a node has been clicked by the defender. If the node has an in-edge from the current node that matches attackersAction, return true. In case of weak bisimulation, there must exist a legal path from the current node to the clicked node (recorded in the successor map). A legal path is (tau)*(attackersAction)(tau)*

Parameters:
node - The node clicked
attackersAction - Other action that must be matched
Returns:
Whether there exists an edge between current node and clicked with name otherAction

step

private void step()

reset

public void reset()
Reset the displayed automaton to its initial state.


stepTo

public void stepTo(java.lang.String nodeName)
Step to a given node in the graph.

Parameters:
nodeName - The name of the node to step to

isActionEnabled

public boolean isActionEnabled(java.lang.String action)
Check to see if there exists an outgoing edge from current node that has label = action.

Parameters:
action - Name of edge label to match
Returns:
If a matching edge exists

noActionEnabled

public boolean noActionEnabled()
Returns:
If current node has no (strong) outgoing edges

getNumberOfStrongChoices

public int getNumberOfStrongChoices()
Return the number of outgoing edges from the current node.

Returns:
The number of outgoing edges from the current node

getStrongChoices

public java.util.Vector<Successor> getStrongChoices()
Used by an attacker to get all choices from the current node that are not weak.

Returns:
The outgoing edges from the current node

getInitialNode

public att.grappa.Node getInitialNode()
Returns:
The initial node of the Grappa graph

getStrongSuccessorMap

private java.util.HashMap<att.grappa.Node,java.util.Vector<Successor>> getStrongSuccessorMap()
Makes a map from each node to its direct successors.

Returns:
A strong successor map

getWeakSuccessorMap

private java.util.HashMap<att.grappa.Node,java.util.Vector<Successor>> getWeakSuccessorMap()
Makes a map from each node to its weak successors. A variation of Warshall's transitive closure algorithm: Starts with the strong succesor map (direct successors), add tau self-loops for each node, and then for each node-triple (i,j,k): for each pair of edges (i--e1-->k) and (k--e2-->j): if e1=tau, add an edge (i--e2-->j) else if e2=tau, add an edge (i--e1-->j).

Returns:
A weak successor map

getEdgeLabels

private java.util.Vector<java.lang.String> getEdgeLabels(java.util.Vector<Successor> toMap,
                                                         att.grappa.Node to)
Get the labels of in-edges of node 'to'. Used for computing a weak successor map.

Parameters:
toMap -
to -
Returns:
The labels of in-edges of node 'to'

getSuccessorMap

public java.util.HashMap<att.grappa.Node,java.util.Vector<Successor>> getSuccessorMap()
Returns:
The successor map