graph

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultWeight is default edge weight
	DefaultWeight = 1.0
)

Variables

View Source
var (
	// ErrInvalidNode is returned when attempting to use an invalid node
	ErrInvalidNode = errors.New("ErrInvalidNode")
	// ErrNodeNotFound is returned when a node could not be found
	ErrNodeNotFound = errors.New("ErrNodeNotFound")
	// ErrEdgeNotFound is returned when an edge could not be found
	ErrEdgeNotFound = errors.New("ErrEdgeNotFound")
	// ErrEdgeNotExist is returned when an edge does not exist
	ErrEdgeNotExist = errors.New("ErrEdgeNotExist")
	// ErrDuplicateNode is returned by store when duplicate nodes are found
	ErrDuplicateNode = errors.New("ErrDuplicateNode")
	// ErrUnknownEntity is returned when requesting an unknown entity
	ErrUnknownEntity = errors.New("ErrUnknownEntity")
	// ErrInvalidEntity is returned when requesting an invalid entity
	ErrInvalidEntity = errors.New("ErrInvalidEntity")
	// ErrMissingEntity is returned when a graph query is missing entity
	ErrMissingEntity = errors.New("ErrMissingEntity")
	// ErrMissingResource is returned by when scrape.Object.Resource() is nil
	ErrMissingResource = errors.New("ErrMissingResource")
	// ErrNotImplemented is returned when requesting functionality that has not been implemented
	ErrNotImplemented = errors.New("ErrNotImplemented")
	// ErrUnsupported is returned when requesting unsupported functionality
	ErrUnsupported = errors.New("ErrUnsupported")
)

Functions

func DOTIDFromEntity added in v0.0.4

func DOTIDFromEntity(o space.Entity) (string, error)

DOTIDFromEntity returns GraphViz DOT ID for given space.Entity. NOTE: the returned DOTIDFromEntity follows the below naming convention: resourceGroup/resourceVersion/resourceKind/entityNamespace/entityName

Types

type DOTEdge

type DOTEdge interface {
	DOTer
	Edge
}

DOTEdge is a GraphViz DOT Edge.

type DOTGraph

type DOTGraph interface {
	Graph
	// DOTID returns grapph DOT ID.
	DOTID() string
	// DOTAttributers returns graph DOT attributes.
	DOTAttributers() (graph, node, edge encoding.Attributer)
	// DOT returns Graphviz DOT graph.
	DOT() (string, error)
}

DOTGraph returns GraphViz DOT graph.

type DOTNode

type DOTNode interface {
	DOTer
	Node
}

DOTNode is a GraphViz DOT Node.

type DOTOption

type DOTOption func(*Options)

DOTOption configures DOT graph.

type DOTOptions

type DOTOptions struct {
	GraphAttrs attrs.DOT
	NodeAttrs  attrs.DOT
	EdgeAttrs  attrs.DOT
}

DOTOptions are DOT graph options.

type DOTer

type DOTer interface {
	// DOTID returns Graphviz DOT ID.
	DOTID() string
	// SetDOTID sets Graphviz DOT ID.
	SetDOTID(string)
}

DOTer implements GraphViz DOT properties.

type Edge

type Edge interface {
	Object
	// FromNode returns the from node of the edge.
	FromNode(context.Context) (Node, error)
	// ToNode returns the to node of the edge.
	ToNode(context.Context) (Node, error)
	// Weight returns edge weight.
	Weight() float64
}

Edge is an edge between two graph nodes.

type Entity

type Entity interface {
	space.Entity
}

Entity is graph entity.

type Graph

type Graph interface {
	// UID returns graph uid.
	UID() uuid.UID
	// Node returns node with given uid.
	Node(context.Context, uuid.UID) (Node, error)
	// Nodes returns all graph nodes.
	Nodes(context.Context) ([]Node, error)
	// Edge returns the edge between the two nodes.
	Edge(ctx context.Context, from, to uuid.UID) (Edge, error)
	// Edges returns all graph edges.
	Edges(context.Context) ([]Edge, error)
}

Graph is a graph of space entities.

type LinkRemover

type LinkRemover interface {
	// RemoveEdge removes edge(s) from the graph.
	RemoveLink(ctx context.Context, from, to uuid.UID) error
}

LinkRemover removes link between two Nodes.

type Node

type Node interface {
	Object
	space.Entity
}

Node is a graph node.

type NodeAdder

type NodeAdder interface {
	// NewNode returns a new Node.
	NewNode(context.Context, space.Entity, ...Option) (Node, error)
	// AddNode adds a new node to the graph.
	AddNode(context.Context, Node) error
}

NodeAdder adds new Nodes to graph.

type NodeLinker

type NodeLinker interface {
	// Link links two nodes and returns the new edge.
	Link(ctx context.Context, from, to uuid.UID, opts ...Option) (Edge, error)
}

NodeLinker links arbitrary nodes in graph.

type NodeRemover

type NodeRemover interface {
	// RemoveNode removes node from the graph.
	RemoveNode(context.Context, uuid.UID) error
}

NodeRemover removes node from Grapg

type Object added in v0.0.4

type Object interface {
	space.Object
}

Object is graph object.

type Option added in v0.0.3

type Option func(*Options)

Option configures Options.

func WithAttrs added in v0.0.3

func WithAttrs(a attrs.Attrs) Option

WithAttrs sets Attrs options

func WithDOTID added in v0.0.3

func WithDOTID(dotid string) Option

WithDOTID sets DOTID Options.

func WithDOTOptions added in v0.0.3

func WithDOTOptions(do DOTOptions) Option

WithDOTOptions sets DOTOptions

func WithUID added in v0.0.3

func WithUID(u uuid.UID) Option

WithUID sets UID Options.

func WithWeight added in v0.0.3

func WithWeight(w float64) Option

WithWeight sets Weight options.

type Options

type Options struct {
	UID        uuid.UID
	DOTID      string
	Attrs      attrs.Attrs
	Weight     float64
	DOTOptions DOTOptions
}

Options are graph options.

type Querier

type Querier interface {
	// Query the graph and return the results.
	Query(context.Context, query.Query) ([]Object, error)
}

Querier queries graph.

type SubGrapher

type SubGrapher interface {
	// SubGraph returns the max subgraph of graph
	// starting at node with given uid up to given depth.
	SubGraph(ctx context.Context, uid uuid.UID, depth int, opts ...Option) (Graph, error)
}

SubGrapher returns the maximal reachable subgraph of graph.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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