code: public static <D, N extends DottableNode<D, N>> String toDot(Collection<? extends N> nodes, String name, String header) {
          StringBuilder buf = new StringBuilder();
          buf.append(String.format("digraph %s {\n", name));
          buf.append(String.format("label = %s;\n", DotVisitor.wrap(header)));
          DotVisitor<D, N> dotVisitor = new DotVisitor<>();
          dotVisitor.visit(nodes, buf);
          buf.append("}\n");
          return buf.toString();
      }
docs: Debugging: dot representation of a set of connected nodes. The resulting
  dot representation will use {@code Node.toString} to display node labels
  and {@code Node.printDependency} to display edge labels. The resulting
  representation is also customizable with a graph name and a header.