dfs

package
v0.0.0-...-09d313d Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2016 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Traverse

func Traverse(g *graph.Graph, source int, visitFn VisitFn)

Traverse performs depth-first search on the graph using source as the starting vertex This runs in O(|V|+|E|) NOTE: that Traverse only goes to all reachable vertices from source, Traverse assumes g is directed Traversal halts if visitFn returns false

Types

type Vertex

type Vertex struct {
	// The source going to the vertex
	Source int
	// The vertex
	Dest int
	// The weight of the edge leading to Dest
	Weight int
	// contains filtered or unexported fields
}

Vertex represents a vertex to be visited

type VisitFn

type VisitFn func(source, toVisit, weight int) bool

VisitFn visits a vertex from the source vertex by an edge with weight VisitFn returns whether to stop traversal or not

Jump to

Keyboard shortcuts

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