graph

package
v0.0.0-...-7450142 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGraph

func NewGraph(m AdjacentMatrix) *graph

NewGraph creates a new graph with the given AdjacentMatrix as underlying matrix.

func NewInMemoryAdjacentMatrix

func NewInMemoryAdjacentMatrix() *inMemoryAdjacentMatrix

NewInMemoryAdjacentMatrix creates a new in-memory adjacent matrix.

Types

type AdjacentMatrix

type AdjacentMatrix interface {
	// AddEdge adds a named edge between vertex p and vertex c.
	AddEdge(name string, p Vertex, c Vertex)
	// AddEdges adds a named edge between vertex p and vertices c.
	AddEdges(name string, p Vertex, c []Vertex)
	// Get gets all vertices of a named edge on vertex v.
	Get(name string, v Vertex) []Vertex
	// NumberOfEdges gets the number of named edges.
	NumberOfEdges(name string) int
}

AdjacentMatrix represents a directed graph through an adjacent matrix.

type Graph

type Graph interface {
	// AddModule adds the given module.
	AddModule(module *spec.Module) error
	// TraverseDependOnEdgesBFS begins at vertex s and traverse over all depend-on edges
	// using breadth-first search.
	// The given function fn is called for each vertex and its direct depend-on edge vertices.
	// The function fn returning true continues the traversal while returning false stops the traversal.
	// The first function fn call has vertex s as parent p.
	TraverseDependOnEdgesBFS(s Vertex, fn func(p Vertex, v []Vertex) bool)
	// TraverseDependOnEdgesDFS begins at Vertex s and traverse over all depend-on edges
	// using depth-first search.
	// The given function fn is called for each vertex and its depend-on edge vertices.
	// The function fn returning true continues the traversal while returning false stops the traversal.
	// The first function fn call has an empty vertex as parent p.
	TraverseDependOnEdgesDFS(s Vertex, fn func(p Vertex, v Vertex) bool)
	// TraverseUsedByEdgesBFS begins at vertex s and traverse over all used-by edges
	// using breadth-first search.
	// The given function fn is called for each vertex and its direct used-by edge vertices.
	// The function fn returning true continues the traversal while returning false stops the traversal.
	// The first function fn call has vertex s as parent p.
	TraverseUsedByEdgesBFS(s Vertex, fn func(p Vertex, v []Vertex) bool)
	// TraverseUsedByEdgesDFS begins at Vertex s and traverse over all used-by edges
	// using depth-first search.
	// The given function fn is called for each vertex and its used-by edge vertices.
	// The function fn returning true continues the traversal while returning false stops the traversal.
	// The first function fn call has an empty vertex as parent p.
	TraverseUsedByEdgesDFS(s Vertex, fn func(p Vertex, v Vertex) bool)
	// TraverseRequiredForEdgesBFS begins at vertex s and traverse over all required-for edges
	// using breadth-first search.
	// The given function fn is called for each vertex and its direct required-for edge vertices.
	// The function fn returning true continues the traversal while returning false stops the traversal.
	// The first function fn call has vertex s as parent p.
	TraverseRequiredForEdgesBFS(s Vertex, fn func(p Vertex, v []Vertex) bool)
	// TraverseRequiredForEdgesDFS begins at Vertex s and traverse over all required-for edges
	// using depth-first search.
	// The given function fn is called for each vertex and its required-for edge vertices.
	// The function fn returning true continues the traversal while returning false stops the traversal.
	// The first function fn call has an empty vertex as parent p.
	TraverseRequiredForEdgesDFS(s Vertex, fn func(p Vertex, v Vertex) bool)
	// TraverseRequireEdgesBFS begins at vertex s and traverse over all require edges
	// using breadth-first search.
	// The given function fn is called for each vertex and its direct require edge vertices.
	// The function fn returning true continues the traversal while returning false stops the traversal.
	// The first function fn call has vertex s as parent p.
	TraverseRequireEdgesBFS(s Vertex, fn func(p Vertex, v []Vertex) bool)
	// TraverseRequireEdgesDFS begins at Vertex s and traverse over all require edges
	// using depth-first search.
	// The given function fn is called for each vertex and its require edge vertices.
	// The function fn returning true continues the traversal while returning false stops the traversal.
	// The first function fn call has an empty vertex as parent p.
	TraverseRequireEdgesDFS(s Vertex, fn func(p Vertex, v Vertex) bool)
}

Graph represents a module graph containing all edges to other modules.

type Vertex

type Vertex struct {
	Namespace string
	Name      string
	Type      string
	Version   string
}

Vertex represents a module within a graph.

func (*Vertex) String

func (v *Vertex) String() string

Jump to

Keyboard shortcuts

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