type Graph … // Metadata implements the [Source] interface func (g *Graph) Metadata(id PackageID) *Package { … } // Update creates a new Graph containing the result of applying the given // updates to the receiver, though the receiver is not itself mutated. As a // special case, if updates is empty, Update just returns the receiver. // // A nil map value is used to indicate a deletion. func (g *Graph) Update(updates map[PackageID]*Package) *Graph { … } // newGraph returns a new metadataGraph, // deriving relations from the specified metadata. func newGraph(pkgs map[PackageID]*Package) *Graph { … } // ReverseReflexiveTransitiveClosure returns a new mapping containing the // metadata for the specified packages along with any package that // transitively imports one of them, keyed by ID, including all the initial packages. func (g *Graph) ReverseReflexiveTransitiveClosure(ids ...PackageID) map[PackageID]*Package { … } // breakImportCycles breaks import cycles in the metadata by deleting // Deps* edges. It modifies only metadata present in the 'updates' // subset. This function has an internal test. func breakImportCycles(metadata, updates map[PackageID]*Package) { … } // cyclic returns a description of a cycle, // if the graph is cyclic, otherwise "". func cyclic(graph map[PackageID]*Package) string { … } // detectImportCycles reports cycles in the metadata graph. It returns a new // unordered array of all cycles (nontrivial strong components) in the // metadata graph reachable from a non-nil 'updates' value. func detectImportCycles(metadata, updates map[PackageID]*Package) [][]*Package { … }