# File lib/chef/cookbook_version_selector.rb, line 41
    def self.create_dependency_graph_from_cookbooks(all_cookbooks)
      dep_graph = DepSelector::DependencyGraph.new

      all_cookbooks.each do |cb_name, cb_versions|
        cb_versions.each do |cb_version|
          cb_version_deps = cb_version.metadata.dependencies
          # TODO [cw. 2011/2/10]: CookbookVersion#version returns a
          # String even though we're storing as a DepSelector::Version
          # object underneath. This should be changed so that we
          # return the object and handle proper serialization and
          # de-serialization. For now, I'm just going to create a
          # Version object from the String representation.
          pv = dep_graph.package(cb_name).add_version(Chef::Version.new(cb_version.version))
          cb_version_deps.each_pair do |dep_name, constraint_str|
            # if the dependency is specified as cookbook::recipe,
            # extract the cookbook component
            dep_cb_name = dep_name.split("::").first
            constraint = Chef::VersionConstraint.new(constraint_str)
            pv.dependencies << DepSelector::Dependency.new(dep_graph.package(dep_cb_name), constraint)
          end
        end
      end

      dep_graph
    end