memory

package
v0.0.0-...-0bc4b66 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Line

type Line struct {
	*entity.Edge
	// contains filtered or unexported fields
}

Line implements graph.WeightedLine

func NewLine

func NewLine(id int64, uid, dotid string, from, to *Node, opts ...entity.Option) *Line

NewLine creates a new line and returns it

func (*Line) Attributes

func (l *Line) Attributes() []encoding.Attribute

Attributes implements store.DOTAttrs

func (*Line) DOTID

func (l *Line) DOTID() string

DOTID returns the edge's DOT ID.

func (*Line) From

func (l *Line) From() graph.Node

From returns the from node of the first non-nil edge, or nil.

func (*Line) ID

func (l *Line) ID() int64

ID is line ID

func (*Line) ReversedLine

func (l *Line) ReversedLine() graph.Line

ReversedLine returns a new line with end points of the pair swapped

func (*Line) SetDOTID

func (l *Line) SetDOTID(id string)

SetDOTID sets the edge's DOT ID.

func (*Line) To

func (l *Line) To() graph.Node

To returns the to node of the first non-nil edge, or nil.

func (Line) Weight

func (l Line) Weight() float64

Weight returns edge weight

type Memory

type Memory struct {
	// contains filtered or unexported fields
}

Memory is in-memory graph store

func NewStore

func NewStore(id string, opts store.Options) (*Memory, error)

NewStore creates new in-memory store and returns it

func (*Memory) Add

func (m *Memory) Add(obj api.Object, opts store.AddOptions) (store.Entity, error)

Add adds obj to the store and returns it

func (*Memory) DOT

func (m *Memory) DOT() (string, error)

DOT returns the GrapViz dot representation of kraph.

func (*Memory) DOTAttributers

func (m *Memory) DOTAttributers() (graph, node, edge encoding.Attributer)

DOTAttributers implements encoding.Attributer

func (*Memory) DOTID

func (m *Memory) DOTID() string

DOTID returns the store DOT ID.

func (*Memory) Delete

func (m *Memory) Delete(e store.Entity, opts store.DelOptions) error

Delete deletes entity e from the memory store

func (*Memory) Edges

func (m *Memory) Edges(uid, vid string) ([]store.Edge, error)

Edges returns all the edges (lines) from u to v if such edges exists and nil otherwise

func (Memory) ID

func (m Memory) ID() string

ID returns store ID

func (m *Memory) Link(from store.Node, to store.Node, opts store.LinkOptions) (store.Edge, error)

Link creates a new edge between the nodes and returns it or it returns an existing edge if the edges between the nodes already exists. It returns error if either of the nodes does not exist in the graph.

func (*Memory) Node

func (m *Memory) Node(id string) (store.Node, error)

Node returns the node with the given ID if it exists in the graph, and nil otherwise.

func (*Memory) Nodes

func (m *Memory) Nodes() ([]store.Node, error)

Nodes returns all the nodes in the graph.

func (Memory) Options

func (m Memory) Options() store.Options

Options returns store options

func (*Memory) Query

func (m *Memory) Query(q *query.Query) ([]store.Entity, error)

Query queries the in-memory graph and returns the matched results.

func (*Memory) QueryLine

func (m *Memory) QueryLine(q *query.Query) ([]*Line, error)

QueryEdge returns all the edges that match given query

func (*Memory) QueryNode

func (m *Memory) QueryNode(q *query.Query) ([]*Node, error)

QueryNode returns all the nodes that match given query.

func (*Memory) SubGraph

func (m *Memory) SubGraph(n store.Node, depth int) (store.Graph, error)

SubGraph returns the subgraph of the node up to given depth

type Node

type Node struct {
	*entity.Node
	// contains filtered or unexported fields
}

Node is memory store node

func NewNode

func NewNode(id int64, uid, dotid string, opts ...entity.Option) *Node

NewNode creates a node and returns it

func (*Node) Attributes

func (n *Node) Attributes() []encoding.Attribute

Attributes implements store.DOTAttrs

func (*Node) DOTID

func (n *Node) DOTID() string

DOTID returns node's GraphVIZ DOT ID.

func (*Node) ID

func (n *Node) ID() int64

ID returns node ID

func (*Node) SetDOTID

func (n *Node) SetDOTID(id string)

SetDOTID sets node's DOT ID.

Jump to

Keyboard shortcuts

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