Documentation ¶
Overview ¶
A memory-efficient graph for large datasets.
Time complexities: Storage: O(V + E) Add Node: O(1) Add Arc: O(1) Remove Node: O(E) Remove Arc: O(1)
Index ¶
- Constants
- type Graph
- func (self *Graph) Add(node *Node)
- func (self *Graph) AddArc(origin *Node, dest *Node)
- func (self *Graph) Adjacent(origin *Node, target *Node) bool
- func (self *Graph) Export(writer io.Writer) error
- func (self *Graph) Get(name string) *Node
- func (self *Graph) Neighbors(origin *Node) []*Node
- func (graph *Graph) PageRank(n int)
- func (self *Graph) PointingTo(dest *Node) []*Node
- func (self *Graph) Remove(node *Node)
- func (self *Graph) RemoveArc(origin *Node, toRemove *Node)
- func (self *Graph) SafeGet(name string) *Node
- func (self *Graph) String() string
- type Node
Constants ¶
const DEFAULT_DAMPING = 0.85
const DEFAULT_ITERATIONS = 15
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Graph ¶
Graph is memory-efficient labeled graph for large datasets.
func Import ¶
Import creates a graph from a gob dump in the given writer. and returns any errors that it encounters.
func (*Graph) Adjacent ¶
Adjacent returns true if the origin node has an arc to the destination node and false otherwise.
func (*Graph) Export ¶
Export writes a gob dump of the graph to the given writer and returns any error that it encounters.
func (*Graph) PageRank ¶
PageRank runs a page rank algorithm on the graph n number of times. It uses DEFAULT_DAMPING, as the damping factor, which is a reasonable value.
The algorithm is described here: http://en.wikipedia.org/wiki/PageRank
and more simply here: http://stackoverflow.com/questions/3950627/python-implementation-of-pagerank
func (*Graph) PointingTo ¶
PointingTo returns all nodes that have arcs to the given node