graph

package
v0.0.0-...-8d18906 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2014 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BetweennessCentrality

func BetweennessCentrality(candidate *Node, nodes []*Node, nbOfNodes int) float32

Betweenness centrality quantifies the number of times a candidate node acts as a bridge along the shortest path between two other nodes.

https://en.wikipedia.org/wiki/Centrality#Betweenness_centrality

The parameter nbOfNodes is the total number of nodes in the graph. The candidate node will be ignored if it is in the list of nodes.

func Dijkstra

func Dijkstra(start *Node)

Dijkstra updates the distances from the start node to *any* other node in the graph.

func ShortestPaths

func ShortestPaths(start, end, middleman *Node) (int, int)

Returns the number of shortest paths between the start node and the end node and the number of shortest paths passing through the middleman.

Types

type Edge

type Edge struct {
	A      *Node
	B      *Node
	Weight float32
}

An Edge link two nodes together with a weight.

type Node

type Node struct {
	ID       string
	Edges    []Edge
	Distance map[string]float32 // Distance (sum of weights) to a given node (by ID)
}

A Node is defined by an ID, a list of edges and the distances to any other node.

func NewNode

func NewNode(id string) *Node

func NextNode

func NextNode(start *Node, edge Edge) *Node

Follow an edge from a starting node.

Jump to

Keyboard shortcuts

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