{"modulePath":"github.com/eric-erki/https-hyperledger.org","version":"v1.4.4","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package graph\n\n## Functions\n\n```go\nfunc CombinationsExceed(n, k, threshold int) bool\n```\nCombinationsExceed computes the number of combinations of choosing K elements from N elements, and returns whether the number of combinations exceeds a given threshold. If n \\\u003c k then it returns false.\n\n## Types\n\n```go\ntype Iterator interface {\n\t// Next returns the next element in the iteration order,\n\t// or nil if there is no such an element\n\tNext() *TreeVertex\n}\n```\nIterator defines an iterator that can be used to traverse vertices of a graph\n\n```go\ntype Tree struct {\n\tRoot *TreeVertex\n}\n```\nTree defines a Tree of vertices of type TreeVertex\n\n```go\nfunc (t *Tree) BFS() Iterator\n```\nBFS returns an iterator that iterates the vertices in a Breadth-First-Search order\n\n```go\nfunc (t *Tree) Permute(combinationUpperBound int) []*Tree\n```\nPermute returns Trees that their vertices and edges all exist in the original tree. The permutations are calculated according to the thresholds of all vertices. The combinationUpperBound is an upper bound of possible combinations of direct descendants of a vertex. If the vertex has a threshold and descendants that result a number of combinations that exceeds the given combinationUpperBound, the descendants are pruned until the number of combinations is lower than the combinationUpperBound. This is done in order to cap the memory usage of the computed result.\n\n```go\ntype TreeVertex struct {\n\tId          string        // id identifies uniquely the TreeVertex in the Tree\n\tData        interface{}   // data holds arbitrary data, to be used by the user of the package\n\tDescendants []*TreeVertex // descendants are the vertices that this TreeVertex is their parent in the tree\n\tThreshold   int           // threshold symbols the count of sub-trees / leaves to pick when creating tree permutations\n}\n```\nTreeVertex defines a vertex of a tree\n\n```go\nfunc NewTreeVertex(id string, data interface{}, descendants ...*TreeVertex) *TreeVertex\n```\nNewTreeVertex creates a new vertex with a given unique id and a given arbitrary data\n\n```go\nfunc (v *TreeVertex) AddDescendant(u *TreeVertex) *TreeVertex\n```\nAddDescendant creates a new vertex who's parent is the invoker vertex, with a given id and data. Returns the new vertex\n\n```go\nfunc (v *TreeVertex) Clone() *TreeVertex\n```\nClone clones the tree who's root vertex is the current vertex.\n\n```go\nfunc (v *TreeVertex) Exists(id string) bool\n```\nExists searches for a vertex who's id is the given id, and returns whether such a vertex was found or not.\n\n```go\nfunc (v *TreeVertex) Find(id string) *TreeVertex\n```\nFind searches for a vertex who's id is the given id. Returns the first vertex it finds with such an Id, or nil if not found\n\n```go\nfunc (v *TreeVertex) IsLeaf() bool\n```\nIsLeaf returns whether the given vertex is a leaf\n\n```go\nfunc (v *TreeVertex) ToTree() *Tree\n```\nToTree creates a Tree who's root vertex is the current vertex\n\n```go\ntype Vertex struct {\n\tId   string\n\tData interface{}\n\t// contains filtered or unexported fields\n}\n```\nVertex defines a vertex of a graph\n\n```go\nfunc NewVertex(id string, data interface{}) *Vertex\n```\nNewVertex creates a new vertex with given id and data\n\n```go\nfunc (v *Vertex) AddNeighbor(u *Vertex)\n```\nAddNeighbor adds the given vertex as a neighbor of the vertex\n\n```go\nfunc (v *Vertex) NeighborById(id string) *Vertex\n```\nNeighborById returns a neighbor vertex with the given id, or nil if no vertex with such an id is a neighbor\n\n```go\nfunc (v *Vertex) Neighbors() []*Vertex\n```\nNeighbors returns the neighbors of the vertex\n\n","path":"github.com/eric-erki/https-hyperledger.org/common/graph","name":"graph","synopsis":"","isRedistributable":true}
