graphs

package
v0.0.0-...-3b8f57b Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2015 License: GPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoHosts = errors.New("Can't have 0 hosts per node")
View Source
var ErrNoNodesGiven = errors.New("No Nodes Given as argument")
View Source
var TRIM bool = false

Functions

func Depth

func Depth(t *Tree) int

func GetFirstFreeNode

func GetFirstFreeNode(nodes []string, mp map[string][]string, curNode string) (
	[]string, map[string][]string, string)

Go through list of nodes(machines) and choose a hostName on the first node that still has room for more hosts on it and is != curNode If such a machine does not exist, loop through the map from machine names to their available host names, and choose a name on the first free machine != curNode Return updated nodes and map (completely full nodes are deleted ) and the chosen hostName

func PrintTreeNode

func PrintTreeNode(t *Tree)

func TrimTree

func TrimTree(newRoot *Tree, oldRoot *Tree, bhMap map[string]bool)

Types

type Float64Slice

type Float64Slice struct {
	A []float64
	I []int // indices
}

func MakeFloat64Slice

func MakeFloat64Slice(A []float64) Float64Slice

func (Float64Slice) Len

func (p Float64Slice) Len() int

func (Float64Slice) Less

func (p Float64Slice) Less(i, j int) bool

func (Float64Slice) Sort

func (p Float64Slice) Sort()

func (Float64Slice) Swap

func (p Float64Slice) Swap(i, j int)

type Graph

type Graph struct {
	Names []string

	Weights [][]float64
	// contains filtered or unexported fields
}

func NewGraph

func NewGraph(names []string) *Graph

func (*Graph) BestConnector

func (g *Graph) BestConnector() int

return the index of the best connector

func (*Graph) LoadEdgeList

func (g *Graph) LoadEdgeList(edgelist []byte)

takes in a byte array representing an edge list and loads the graph

func (*Graph) MST

func (g *Graph) MST() *Tree

func (*Graph) Tree

func (g *Graph) Tree(nlevels int) *Tree

nlevels : [0:n-1]

type Tree

type Tree struct {
	Name string `json:"name"`
	// hex encoded public and private keys
	PriKey   string  `json:"prikey,omitempty"`
	PubKey   string  `json:"pubkey,omitempty"`
	Children []*Tree `json:"children,omitempty"`
}

tree easy to deal with default json encoding can be read as the Tree section of a config file

func ColorTree

func ColorTree(nodeNames []string, hostAddr []string, hostsPerNode int, bf int, startM string, mp map[string][]string) (
	*Tree, []string, error)

func TreeFromList

func TreeFromList(nodeNames []string, hostsPerNode int, bf int, startMachine ...string) (
	*Tree, []string, int, error)

Given a list of machine names, a number of hosts per machine(node), and a branching factor Return a Tree that meets the branching factor restriction, and has no two adjacent nodes in the Tree running as hosts on the same machine Also returns a list of the host names created and their ports

func TrimLastIncompleteLevel

func TrimLastIncompleteLevel(root *Tree, hosts []string, depths []int, bf int) (*Tree, []string)

func (*Tree) GenKeys

func (t *Tree) GenKeys(suite abstract.Suite, rand abstract.Cipher)

generate keys for the tree

func (*Tree) TraverseTree

func (t *Tree) TraverseTree(f func(*Tree))

Jump to

Keyboard shortcuts

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