memory

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

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

Go to latest
Published: Jul 2, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultLabel is memory graph default label.
	DefaultLabel = "InMemoryGraph"
	// DefaultType is default graph type.
	DefaultType = "weighted_directed"
	// DefaultWeight is default edge weight.
	DefaultWeight = 1.0
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Edge

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

Edge is a weighted graph edge.

func EdgeDeepCopy

func EdgeDeepCopy(e *Edge) *Edge

EdgeDeepCopy makes a deep copy of Edge and returns it

func NewEdge

func NewEdge(from, to gonum.Node, opts ...Option) (*Edge, error)

NewEdge creates a new edge and returns it.

func (Edge) Attributes

func (e Edge) Attributes() []encoding.Attribute

Attributes returns node DOT attributes.

func (*Edge) Attrs

func (e *Edge) Attrs() map[string]interface{}

Attrs returns node attributes.

func (Edge) Color

func (e Edge) Color() color.RGBA

Color returns edge color.

func (*Edge) From

func (e *Edge) From() gonum.Node

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

func (Edge) Label

func (e Edge) Label() string

Label returns edge label.

func (*Edge) ReversedEdge

func (e *Edge) ReversedEdge() gonum.Edge

ReversedEdge returns a new edge with end points of the pair swapped.

func (*Edge) SetLabel

func (e *Edge) SetLabel(l string)

SetLabel sets edge label.

func (*Edge) SetUID

func (e *Edge) SetUID(uid string)

SetUID sets UID.

func (*Edge) SetWeight

func (e *Edge) SetWeight(w float64)

SetWeight sets edge weight.

func (Edge) Shape

func (e Edge) Shape() string

Shape returns edge shape.

func (Edge) Style

func (e Edge) Style() string

Style returns edge style.

func (*Edge) To

func (e *Edge) To() gonum.Node

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

func (Edge) UID

func (e Edge) UID() string

UID returns edge UID.

func (Edge) Weight

func (e Edge) Weight() float64

Weight returns edge weight

type Graph

type Graph struct {
	*simple.WeightedDirectedGraph
	// contains filtered or unexported fields
}

Graph is an in-memory graph.

func GraphDeepCopy

func GraphDeepCopy(g *Graph) *Graph

GraphDeepCopy return s deep copy of a memory graph.

func NewGraph

func NewGraph(opts ...Option) (*Graph, error)

NewGraph creates a new graph and returns it.

func (*Graph) Attrs

func (g *Graph) Attrs() map[string]interface{}

Attrs returns graph attributes.

func (Graph) HasEdgeFromTo

func (g Graph) HasEdgeFromTo(uid, vid int64) bool

HasEdgeFromTo returns whether an edge exist between two nodoes with the given IDs.

func (Graph) Label

func (g Graph) Label() string

Label returns graph label.

func (*Graph) SetLabel

func (g *Graph) SetLabel(l string)

SetLabel sets label.

func (*Graph) SetUID

func (g *Graph) SetUID(uid string)

SetUID sets UID.

func (Graph) To

func (g Graph) To(id int64) gonum.Nodes

To returns all nodes that can reach directly to the node with the given ID.

func (Graph) Type

func (g Graph) Type() string

Type returns the type of graph.

func (Graph) UID

func (g Graph) UID() string

UID returns graph UID.

type Node

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

Node is a graph node.

func NewNode

func NewNode(id int64, opts ...Option) (*Node, error)

NewNode creates a new Node and returns it.

func NodeDeepCopy

func NodeDeepCopy(n *Node) *Node

NodeDeepCopy makes a deep copy of Node and returns it.

func (Node) Attributes

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

Attributes returns node DOT attributes.

func (*Node) Attrs

func (n *Node) Attrs() map[string]interface{}

Attrs returns node attributes.

func (Node) Color

func (n Node) Color() color.RGBA

Color returns node color.

func (Node) DOTID

func (n Node) DOTID() string

DOTID returns GraphVIz DOT ID.

func (Node) ID

func (n Node) ID() int64

ID returns node ID.

func (Node) Label

func (n Node) Label() string

Label returns node label.

func (*Node) SetDOTID

func (n *Node) SetDOTID(dotid string)

SetDOTID sets GraphVIz DOT ID.

func (*Node) SetLabel

func (n *Node) SetLabel(l string)

SetLabel sets node label.

func (*Node) SetUID

func (n *Node) SetUID(uid string)

SetUID sets UID.

func (Node) Shape

func (n Node) Shape() string

Shape returns node shape.

func (Node) Type

func (n Node) Type() string

Type returns the type of node style.

func (Node) UID

func (n Node) UID() string

UID returns node UID.

type Option

type Option func(*Options)

Option is functional graph option.

func WithAttrs

func WithAttrs(a map[string]interface{}) Option

WithAttrs sets Attrs option,

func WithDotID

func WithDotID(d string) Option

WithDotID sets DotID option.

func WithLabel

func WithLabel(l string) Option

WithLabel sets Label option.

func WithStyle

func WithStyle(s style.Style) Option

WithStyle sets Style option.

func WithType

func WithType(t string) Option

WithType sets Type option.

func WithUID

func WithUID(u string) Option

WithUID sets UID option.

func WithWeight

func WithWeight(w float64) Option

WithWeight sets Weight option.

type Options

type Options struct {
	// UID configures UID
	UID string
	// Label configures Label.
	Label string
	// Attrs configures Attrs.
	Attrs map[string]interface{}
	// DotID configures DOT ID
	DotID string
	// Type is graph type
	Type string
	// Weight configures weight.
	Weight float64
	// Style configures style.
	Style style.Style
}

Options configure graph.

Jump to

Keyboard shortcuts

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