Documentation ¶
Index ¶
Constants ¶
View Source
const (
// MaxVertices is the maximum size of the adjacent matrix
MaxVertices = 1000
)
Variables ¶
View Source
var ( // ErrLowBound when the vertex's index is smaller than 0 ErrLowBound = errors.New("vertex out of range: lower bound violation") // ErrUpBound when the vertex's index is bigger than the maximum ErrUpBound = errors.New("vertex out of range: upper bound violation") )
Functions ¶
func BoundCheck ¶
BoundCheck checks whether the vertex index exceeds the allowed bound by the graph. This is an helper function the client graph package can use to check bound
Also see MustBoundCheck
func Loads ¶
func Loads(graphCFn createGraphFunc)
Loads loads the graph constructor for this package
func MustBoundCheck ¶
MustBoundCheck is BoundCheck, but panics when error is not nil
Types ¶
type Interface ¶
type Interface interface { // returns the total number of vertices in the graph Nvertices() int // Weight returns the weight of the edge between 2 vertices. If // no edge exists, weight returns false as the second argument Weight(x, y int) (int, bool) // InDegree returns the in-degree of a vertex InDegree(v int) int // OutDegree returns the out-degree of a vertex OutDegree(v int) int // InsertEdge adds an edge to the graph. // If the inserted edge is directed, only one edge is inserted. // Otherwise, two edges (x,y) and (y,x) are inserted. // If the inserted edge is out of bound the total number of vertices is // scaled up and limited to graph.MaxVertices. InsertEdge(x, y, weight int, directed bool) // DeleteEdge removes an edge. If the inserted edge is directed, only one edge // is deleted. Otherwise, two edges are deleted. DeleteEdge(x, y int, directed bool) }
Interface represents a directed graph
Click to show internal directories.
Click to hide internal directories.