def follow_dependencies(subset, package_list):
 dependency_graph = get_dependency_graph(package_list)
 curr_pkgs = None
 updated_pkgs = set(subset)
 while (curr_pkgs != updated_pkgs):
  curr_pkgs = updated_pkgs
  updated_pkgs = set(curr_pkgs)
  for package in curr_pkgs:
   updated_pkgs.update(dependency_graph[package])
 return sorted(curr_pkgs)

def follow_dependencies ( subset , package_list ) : dependency_graph = get_dependency_graph ( package_list ) curr_pkgs = None updated_pkgs = set ( subset ) while ( curr_pkgs != updated_pkgs ) : curr_pkgs = updated_pkgs updated_pkgs = set ( curr_pkgs ) for package in curr_pkgs : updated_pkgs . update ( dependency_graph [ package ] ) return sorted ( curr_pkgs )
get a directed graph of package dependencies .