graph

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Graph-like operations on top of storage

The package is in work-in-progress status.

Classical data structure where each node (element) addressed by unique key (id) and should have only one value and multiple links: keys of another nodes. Such data structure should well reflect real world relationship like so: social network (person can have friends), users accounts (several accounts for one user) and so on.

            NODE                    NODE
         +--------+              +--------+
node id  |  key   |     +------> |  key   |
         +--------+     |        | ....   |
payload  | value  |     |        +--------+
         +--------+     |
         |  key0  |  ---+
links    |  key1  |
         |  ...   |
         +--------+

Graph may contain only forward link as well as backwards links also. It depends of implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Naive

func Naive(storage storages.Storage, key NodeKey) *graphNode

Naive graph stores value and links in one storage cell with GOB encoding (could be changed in a future)

Types

type Node

type Node interface {
	// node payload
	Data() ([]byte, error)
	// node id (key)
	Key() NodeKey
	// list of linked keys to the node
	Linked() ([]NodeKey, error)
	// update node payload
	SetData(value []byte) error
	// update node links
	SetLinked(keys []NodeKey) error
	// open another node by key using current node implementation of graph
	Open(key NodeKey) Node
}

type NodeKey

type NodeKey []byte

Node key

Jump to

Keyboard shortcuts

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