data

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2022 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package data contains classes and functions to handle graph data.

Nodes

Nodes are items stored in the graph. The graphNode object is the minimal implementation of the Node interface and represents a simple node. Setting a nil value to an attribute is equivalent to removing the attribute. An attribute value can be any object which can be serialized by gob.

Edges

Edges are items stored in the graph. Edges connect nodes. The graphEdge object is the minimal implementation of the Edge interface and represents a simple edge. Setting a nil value to an attribute is equivalent to removing the attribute. An attribute value can be any object which can be serialized by gob.

Index

Constants

View Source
const EdgeEnd1Cascading = "end1cascading"

EdgeEnd1Cascading is the flag to cascade delete operations from the first end

View Source
const EdgeEnd1CascadingLast = "end1cascadinglast"

EdgeEnd1CascadingLast is a flag to indicate that cascading delete operations are only executed on the last/only edge of a kind

View Source
const EdgeEnd1Key = "end1key"

EdgeEnd1Key is the key of the first end

View Source
const EdgeEnd1Kind = "end1kind"

EdgeEnd1Kind is the kind of the first end

View Source
const EdgeEnd1Role = "end1role"

EdgeEnd1Role is the role of the first end

View Source
const EdgeEnd2Cascading = "end2cascading"

EdgeEnd2Cascading is the flag to cascade delete operations from the second end

View Source
const EdgeEnd2CascadingLast = "end2cascadinglast"

EdgeEnd2CascadingLast is a flag to indicate that cascading delete operations are only executed on the last/only edge of a kind

View Source
const EdgeEnd2Key = "end2key"

EdgeEnd2Key is the key of the second end

View Source
const EdgeEnd2Kind = "end2kind"

EdgeEnd2Kind is the kind of the second end

View Source
const EdgeEnd2Role = "end2role"

EdgeEnd2Role is the role of the second end

View Source
const NodeKey = "key"

NodeKey is the key attribute for a node

View Source
const NodeKind = "kind"

NodeKind is the kind attribute for a node

View Source
const NodeName = "name"

NodeName is the name attribute for a node

Variables

This section is empty.

Functions

func NodeCompare

func NodeCompare(node1 Node, node2 Node, attrs []string) bool

NodeCompare compares node attributes.

func NodeSort

func NodeSort(list []Node)

NodeSort sorts a list of nodes.

Types

type Edge

type Edge interface {
	Node

	/*
		End1Key returns the key of the first end of this edge.
	*/
	End1Key() string

	/*
		End1Kind returns the kind of the first end of this edge.
	*/
	End1Kind() string

	/*
		End1Role returns the role of the first end of this edge.
	*/
	End1Role() string

	/*
		End1IsCascading is a flag to indicate that delete operations from this
		end are cascaded to the other end.
	*/
	End1IsCascading() bool

	/*
		End1IsCascadingLast is a flag to indicate that cascading delete
		operations are only executed if this is the last/only edge of
		this kind to the other end. The flag is ignored if End1IsCascading is
		false.
	*/
	End1IsCascadingLast() bool

	/*
		End2Key returns the key of the second end of this edge.
	*/
	End2Key() string

	/*
		End2Kind returns the kind of the second end of this edge.
	*/
	End2Kind() string

	/*
		End2Role returns the role of the second end of this edge.
	*/
	End2Role() string

	/*
		End2IsCascading is a flag to indicate that delete operations from this
		end are cascaded to the other end.
	*/
	End2IsCascading() bool

	/*
		End2IsCascadingLast is a flag to indicate that cascading delete
		operations are only executed if this is the last/only edge of
		this kind to the other end. The flag is ignored if End2IsCascading is
		false.
	*/
	End2IsCascadingLast() bool

	/*
		Spec returns the spec for this edge from the view of a specified endpoint.
		A spec is always of the form: <End Role>:<Kind>:<End Role>:<Other node kind>
	*/
	Spec(key string) string

	/*
		OtherEndKey returns the key of the endpoint which is on the other side
		from the given key.
	*/
	OtherEndKey(key string) string

	/*
		OtherEndKind returns the kind of the endpoint which is on the other side
		from the given key.
	*/
	OtherEndKind(key string) string
}

Edge models edges in the graph

func NewGraphEdge

func NewGraphEdge() Edge

NewGraphEdge creates a new Edge instance.

func NewGraphEdgeFromNode

func NewGraphEdgeFromNode(node Node) Edge

NewGraphEdgeFromNode creates a new Edge instance.

type Node

type Node interface {

	/*
	   Key returns a potentially non human-readable unique key for this node.
	*/
	Key() string

	/*
	   Name returns a human-readable name for this node.
	*/
	Name() string

	/*
	   Kind returns a human-readable kind for this node.
	*/
	Kind() string

	/*
		Data returns the node data of this node.
	*/
	Data() map[string]interface{}

	/*
		Attr returns an attribute of this node.
	*/
	Attr(attr string) interface{}

	/*
		SetAttr sets an attribute of this node. Setting a nil
		value removes the attribute.
	*/
	SetAttr(attr string, val interface{})

	/*
		IndexMap returns a representation of this node as a string map which
		can be used to provide a full-text search.
	*/
	IndexMap() map[string]string

	/*
	   String returns a string representation of this node.
	*/
	String() string
}

Node models nodes in the graph

func CopyNode

func CopyNode(node Node) Node

CopyNode returns a shallow copy of a given node.

func NewGraphNode

func NewGraphNode() Node

NewGraphNode creates a new Node instance.

func NewGraphNodeFromMap

func NewGraphNodeFromMap(data map[string]interface{}) Node

NewGraphNodeFromMap creates a new Node instance.

func NodeClone

func NodeClone(node Node) Node

NodeClone clones a node.

func NodeMerge

func NodeMerge(node1 Node, node2 Node) Node

NodeMerge merges two nodes together in a third node. The node values are copied by reference.

type NodeSlice

type NodeSlice []Node

NodeSlice attaches the methods of sort.Interface to []Node, sorting in increasing order by key and kind.

func (NodeSlice) Len

func (p NodeSlice) Len() int

Len belongs to the sort.Interface.

func (NodeSlice) Less

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

Less belongs to the sort.Interface.

func (NodeSlice) Swap

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

Swap belongs to the sort.Interface.

Jump to

Keyboard shortcuts

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