code: public static <T> void write(final File file, final Graph<T> graph) throws IOException {
      final StringBuilder sb = new StringBuilder(String.format("strict graph {%n"));
  
      Set<Node<T>> doneNodes = new LinkedHashSet<>();
      for (Node<T> d : graph.nodes()) {
        for (Node<T> n : d.neighbours())
          if (!doneNodes.contains(n))
            sb.append("  ").append(d.content()).append(" -- ").append(n.content()).append(System.lineSeparator());
        doneNodes.add(d);
      }
      for (Node<T> d : graph.nodes()) {
        if (d.neighbours().isEmpty()) {
          sb.append("  ").append(d.content()).append(System.lineSeparator());
        }
      }
      sb.append("}");
  
      try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8))) {
        writer.append(sb);
        writer.flush();
      }
    }
docs: Writes a given graph's internal data structure as a dot file.
  @param file  the file of the dot file to write
  @param graph the graph
  @param <T>   the type of the graph content
  @throws IOException if there was a problem writing the file