def to_graphviz(layers: nil)
      node_names = friendly_unique_node_names
      s = []

      s << "digraph {"
      (layers || [nodes]).each_with_index do |layer_nodes, i|
        s << "  subgraph cluster_#{i} {  label = \"Layer #{i}\";" unless layers.nil?

        layer_nodes.each do |n|
          s << "    #{node_names[n]}; \t// #{n.inspect}"
        end

        s << "  }" unless layers.nil?
      end

      s << "  // edges:"
      edges.each do |from, to|
        s << "  #{node_names[from]} -> #{node_names[to]};"
      end
      s << "}"
      s.join("\n") + "\n"
    end
def to_graphviz(layers: nil)
      node_names = friendly_unique_node_names
      s = []

      s << "digraph {"
      (layers || [nodes]).each_with_index do |layer_nodes, i|
        s << "  subgraph cluster_#{i} {  label = \"Layer #{i}\";" unless layers.nil?

        layer_nodes.each do |n|
          s << "    #{node_names[n]}; \t// #{n.inspect}"
        end

        s << "  }" unless layers.nil?
      end

      s << "  // edges:"
      edges.each do |from, to|
        s << "  #{node_names[from]} -> #{node_names[to]};"
      end
      s << "}"
      s.join("\n") + "\n"
    end
@param nodes [Array<InventoryRefresh::InventoryCollection>] List of Inventory collection nodes
 Returns graph in GraphViz format, as a string. So it can be displayed.

 @param layers [Array<Array>] Array of arrays(layers) of InventoryCollection objects
 @return [String] Graph in GraphViz format