graph

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2026 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildOptions

type BuildOptions struct {
	// MaxDepth is the maximum number of path segments a module name may have.
	// Deeper paths are collapsed to their ancestor. Defaults to 4 when 0.
	MaxDepth int
	// MaxModules caps how many modules are retained. 0 means no cap.
	MaxModules int
}

BuildOptions configures the behaviour of Build.

type Edge

type Edge struct {
	From  string
	To    string
	Count int // number of imports crossing this edge
}

Edge represents a dependency relationship between two modules.

type Graph

type Graph struct {
	// contains filtered or unexported fields
}

Graph holds the full dependency graph built from parsed files.

func Build

func Build(files []*parser.FileInfo, opts BuildOptions) *Graph

Build constructs a dependency Graph from a slice of parsed FileInfo.

func (*Graph) Edges

func (g *Graph) Edges() []Edge

Edges returns all edges sorted by (From, To).

func (*Graph) Entrypoints

func (g *Graph) Entrypoints() []string

Entrypoints returns file paths that were flagged as IsEntrypoint.

func (*Graph) Isolated

func (g *Graph) Isolated() []string

Isolated returns the names of modules that have no incoming and no outgoing dependency edges, sorted alphabetically.

func (*Graph) Module

func (g *Graph) Module(name string) *Module

Module returns a module by name, or nil if not found.

func (*Graph) Modules

func (g *Graph) Modules() []*Module

Modules returns all modules sorted by name.

func (*Graph) MostDepended

func (g *Graph) MostDepended() []string

MostDepended returns module names sorted by DependedBy count descending. Ties are broken alphabetically.

type Module

type Module struct {
	Name            string
	FileCount       int
	Files           []string // basenames of files in this module
	Exports         []string
	TypeDefs        map[string]string
	DependsOn       []string
	DependedBy      []string
	Languages       []string
	PrimaryLanguage string
	LineCount       int
	// contains filtered or unexported fields
}

Module represents a logical grouping of source files by directory.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL