public String toDot(){
  StringBuilder b=new StringBuilder();
  b.append("digraph Automaton {\n");
  b.append("  rankdir = LR\n");
  final int numStates=getNumStates();
  if (numStates > 0) {
    b.append("  initial [shape=plaintext,label=\"0\"]\n");
    b.append("  initial -> 0\n");
  }
  Transition t=new Transition();
  for (int state=0; state < numStates; state++) {
    b.append("  ");
    b.append(state);
    if (isAccept(state)) {
      b.append(" [shape=doublecircle,label=\"" + state + "\"]\n");
    }
 else {
      b.append(" [shape=circle,label=\"" + state + "\"]\n");
    }
    int numTransitions=initTransition(state,t);
    for (int i=0; i < numTransitions; i++) {
      getNextTransition(t);
      assert t.max >= t.min;
      b.append("  ");
      b.append(state);
      b.append(" -> ");
      b.append(t.dest);
      b.append(" [label=\"");
      appendCharString(t.min,b);
      if (t.max != t.min) {
        b.append('-');
        appendCharString(t.max,b);
      }
      b.append("\"]\n");
    }
  }
  b.append('}');
  return b.toString();
}

public String toDot ( ) { StringBuilder b = new StringBuilder ( ) ; b . append ( "digraph Automaton {\n" ) ; b . append ( "  rankdir = LR\n" ) ; final int numStates = getNumStates ( ) ; if ( numStates > 0 ) { b . append ( "  initial [shape=plaintext,label=\"0\"]\n" ) ; b . append ( "  initial -> 0\n" ) ; } Transition t = new Transition ( ) ; for ( int state = 0 ; state < numStates ; state ++ ) { b . append ( "  " ) ; b . append ( state ) ; if ( isAccept ( state ) ) { b . append ( " [shape=doublecircle,label=\"" + state + "\"]\n" ) ; } else { b . append ( " [shape=circle,label=\"" + state + "\"]\n" ) ; } int numTransitions = initTransition ( state , t ) ; for ( int i = 0 ; i < numTransitions ; i ++ ) { getNextTransition ( t ) ; assert t . max >= t . min ; b . append ( "  " ) ; b . append ( state ) ; b . append ( " -> " ) ; b . append ( t . dest ) ; b . append ( " [label=\"" ) ; appendCharString ( t . min , b ) ; if ( t . max != t . min ) { b . append ( '-' ) ; appendCharString ( t . max , b ) ; } b . append ( "\"]\n" ) ; } } b . append ( '}' ) ; return b . toString ( ) ; }
returns the dot ( graphviz ) representation of this automaton . this is extremely useful for visualizing the automaton .
