code: public static void toDot(Writer w, FSA fsa, int node) throws IOException {
      w.write("digraph Automaton {\n");
      w.write("  rankdir = LR;\n");
  
      final BitSet visited = new BitSet();
  
      w.write("  stop [shape=doublecircle,label=\"\"];\n");
      w.write("  initial [shape=plaintext,label=\"\"];\n");
      w.write("  initial -> " + node + "\n\n");
  
      visitNode(w, 0, fsa, node, visited);
      w.write("}\n");
    }
docs: Saves the right-language reachable from a given FSA node, formatted as an
  input for the graphviz package (expressed in the <code>dot</code>
  language), to the given writer.
  
  @param w The writer to write dot language description of the automaton.
  @param fsa The automaton to visualize.
  @param node Starting node (subgraph will be visualized unless it's the automaton's root node).
  @throws IOException Rethrown if an I/O exception occurs.