graph

package
v1.0.0-beta8 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Copyright 2021 Cloud Privacy Labs, LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckIsomorphism

func CheckIsomorphism(g1, g2 Graph, nodeEquivalenceFunc func(n1, n2 Node) bool, edgeEquivalenceFunc func(e1, e2 Edge) bool) bool

CheckIsomoprhism checks to see if graphs given are equal as defined by the edge equivalence and node equivalence functions. The nodeEquivalenceFunction will be called for nodes whose labels are the same. The edgeEquivalenceFunction will be called for edges connecting equivalent nodes with the same labels.

Node isomorphism check will fail if one node is equivalent to multiple nodes

func CollectAllPaths

func CollectAllPaths(graph Graph, firstLeg EdgeIterator, edgeFilter func(Edge) bool, dir EdgeDir, min, max int, accumulator func([]Edge) bool)

CollectAllPaths iterates the variable length paths that have the edges in firstLeg. For each edge, it calls the edgeFilter function. If the edge is accepted, it recursively descends and calls accumulator.AddPath for each discovered path until AddPath returns false

func ComparePropertyValue

func ComparePropertyValue(a, b interface{}) int

ComparePropertyValue compares a and b. They both must be of the same type. Supported types are

int
string
[]int
[]string
[]interface

The []interface must have one of the supported types as its elements

If one of the values implement GetNativeValue() method, then it is called to get the underlying value

func CopyGraph

func CopyGraph(source, target Graph, clonePropertyFunc func(string, interface{}) interface{}) map[Node]Node

CopyGraph copies source graph into target, using clonePropertyFunc to clone properties

func CopyGraphf

func CopyGraphf(source Graph, copyNodeFunc func(Node, map[Node]Node) Node, copyEdgeFunc func(Edge, map[Node]Node) Edge) map[Node]Node

CopyGraphf copies source graph into target, using the copeNodeFunc func to clone nodes. copyNodeFunc may return nil to prevent copying a node

func CopySubgraph

func CopySubgraph(sourceNode Node, target Graph, clonePropertyFunc func(string, interface{}) interface{}, nodeMap map[Node]Node)

CopySubgraph copies all nodes that are accessible from sourceNode to the target graph

func DefaultDOTEdgeRender

func DefaultDOTEdgeRender(fromNode, toNode string, edge Edge, w io.Writer) error

DefaultDOTEdgeRender renders the edge with a label if there is one, or without a label if there is not a label.

func DefaultDOTNodeRender

func DefaultDOTNodeRender(ID string, node Node, w io.Writer) error

DefaultDOTNodeRender renders the node with the given ID. If the node has a label, it uses that label, otherwise node is not labeled.

func ForEachNode

func ForEachNode(g Graph, predicate func(Node) bool) bool

ForEachNode iterates through all the nodes of g until predicate returns false or all nodes are processed.

func GetEdgeFilterFunc

func GetEdgeFilterFunc(labels StringSet, properties map[string]interface{}) func(Edge) bool

GetEdgeFilterFunc returns a function that can be used to pass edges that have at least one of the specified labels, with correct property values

func GetNodeFilterFunc

func GetNodeFilterFunc(labels StringSet, properties map[string]interface{}) func(Node) bool

GetNodeFilterFunc returns a function that can be used to pass nodes that have all the specified labels, with correct property values

Types

type DOTRenderer

type DOTRenderer struct {
	// NodeRenderer renderes a node. If the node is to be excluded, returns false.
	NodeRenderer func(string, Node, io.Writer) (bool, error)
	// EdgeRenderer renders an edge. The from and to nodes are rendered
	// if this is called. If the edge is to be excluded, returns false
	EdgeRenderer func(fromID string, toID string, edge Edge, w io.Writer) (bool, error)
}

DOTRenderer renders a graph in Graphviz dot format

func (DOTRenderer) Render

func (d DOTRenderer) Render(g Graph, graphName string, out io.Writer) error

Render writes a DOT graph with the given name

func (DOTRenderer) RenderEdge

func (d DOTRenderer) RenderEdge(fromID, toID string, edge Edge, w io.Writer) (bool, error)

RenderEdge renders an edge. If edge renderer is not set, call the default rendeded

func (DOTRenderer) RenderNode

func (d DOTRenderer) RenderNode(ID string, node Node, w io.Writer) (bool, error)

RenderNode renders a node. If node renderer is not set, calls the default renderer

func (DOTRenderer) RenderNodesEdges

func (d DOTRenderer) RenderNodesEdges(g Graph, out io.Writer) error

type DefaultMatchAccumulator

type DefaultMatchAccumulator struct {
	// Each element of the paths is either a Node or []Edge
	Paths   []interface{}
	Symbols []map[string]interface{}
}

func (*DefaultMatchAccumulator) GetHeadNodes

func (acc *DefaultMatchAccumulator) GetHeadNodes() []Node

Returns the unique nodes in the accumulator that start a path

func (*DefaultMatchAccumulator) StoreResult

func (acc *DefaultMatchAccumulator) StoreResult(_ *MatchContext, path interface{}, symbols map[string]interface{})

type Edge

type Edge interface {
	GetGraph() Graph

	GetLabel() string
	SetLabel(string)

	GetFrom() Node
	GetTo() Node

	GetProperty(string) (interface{}, bool)
	SetProperty(string, interface{})
	RemoveProperty(string)
	// Iterate properties until function returns false. Returns false if
	// function returns false, true if all properties are iterated (may be none)
	ForEachProperty(func(string, interface{}) bool) bool

	// Remove an edge
	Remove()
}

func CopyEdge

func CopyEdge(edge Edge, target Graph, clonePropertyFunc func(string, interface{}) interface{}, nodeMap map[Node]Node) Edge

CopyEdge copies the edge into graph

func EdgeSlice

func EdgeSlice(in EdgeIterator) []Edge

EdgeSlice reads all the remaining items of an edge iterator and returns them in a slice

type EdgeDir

type EdgeDir int

EdgeDir is used to show edge direction

const (
	IncomingEdge EdgeDir = -1
	OutgoingEdge EdgeDir = 1
)

Incoming and outgoing edge direction constants

type EdgeIterator

type EdgeIterator interface {
	Iterator
	// Returns the current edge
	Edge() Edge
}

EdgeIterator iterates the edges of an underlying list

func NewEdgeIterator

func NewEdgeIterator(edges ...Edge) EdgeIterator

type EdgeMap

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

An EdgeMap stores edges indexed by edge label

func (*EdgeMap) Add

func (em *EdgeMap) Add(edge *OCEdge)

func (EdgeMap) IsEmpty

func (em EdgeMap) IsEmpty() bool

func (EdgeMap) Iterator

func (em EdgeMap) Iterator() EdgeIterator

func (EdgeMap) IteratorAnyLabel

func (em EdgeMap) IteratorAnyLabel(labels StringSet) EdgeIterator

func (EdgeMap) IteratorLabel

func (em EdgeMap) IteratorLabel(label string) EdgeIterator

func (EdgeMap) Len

func (em EdgeMap) Len() int

func (EdgeMap) Remove

func (em EdgeMap) Remove(edge *OCEdge)

type EdgeSet

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

EdgeSet keeps an unordered set of edges

func (*EdgeSet) Add

func (set *EdgeSet) Add(edge *OCEdge)

func (EdgeSet) Iterator

func (set EdgeSet) Iterator() EdgeIterator

func (EdgeSet) Len

func (set EdgeSet) Len() int

func (EdgeSet) Remove

func (set EdgeSet) Remove(edge *OCEdge)

func (EdgeSet) Slice

func (set EdgeSet) Slice() []Edge

type ErrEdgeVariableExpected

type ErrEdgeVariableExpected string

func (ErrEdgeVariableExpected) Error

func (e ErrEdgeVariableExpected) Error() string

type ErrNodeVariableExpected

type ErrNodeVariableExpected string

func (ErrNodeVariableExpected) Error

func (e ErrNodeVariableExpected) Error() string

type FastSet

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

A FastSet is a set of objects with constant-time insertion/deletion, with iterator support

func NewFastSet

func NewFastSet() *FastSet

func (*FastSet) Add

func (f *FastSet) Add(item interface{})

func (FastSet) Has

func (f FastSet) Has(item interface{}) bool

func (FastSet) Iterator

func (f FastSet) Iterator() Iterator

func (FastSet) Len

func (f FastSet) Len() int

func (*FastSet) Remove

func (f *FastSet) Remove(item interface{})

type Graph

type Graph interface {
	NewNode(labels []string, properties map[string]interface{}) Node

	// NewEdge will add the nodes to the graph if they are not in the graph, and connect them
	NewEdge(from, to Node, label string, properties map[string]interface{}) Edge

	GetNodes() NodeIterator
	GetNodesWithAllLabels(StringSet) NodeIterator
	GetNodesWithProperty(string) NodeIterator
	NumNodes() int

	GetEdges() EdgeIterator
	GetEdgesWithAnyLabel(StringSet) EdgeIterator
	GetEdgesWithProperty(string) EdgeIterator
	NumEdges() int
}

A Graph is a collection of nodes and edges.

type Iterator

type Iterator interface {
	// Next moves to the next item in the iterator, and returns true if
	// move was successful. If there are no next items remaining, returns false
	Next() bool

	// Value returns the current item in the iterator. This is undefined
	// before the first call to Next, and after Next returns false.
	Value() interface{}

	// MaxSize returns an estimation of maximum number of elements. If unknown, returns -1
	MaxSize() int
}

An Iterator iterates the items of a collection

func MultiIterator

func MultiIterator(iterators ...Iterator) Iterator

MultiIterator returns an iterator that contatenates all the given iterators

type MatchAccumulator

type MatchAccumulator interface {
	// path is either a Node or []Edge, the matching path symbols
	// contains the current values for each symbol. The values of the
	// map is either Node or []Edge
	StoreResult(ctx *MatchContext, path interface{}, symbols map[string]interface{})
}

type MatchContext

type MatchContext struct {
	Graph Graph
	// These are symbols that are used as constraints in the matching process.
	Symbols map[string]*PatternSymbol

	// localSymbols are symbols defined in the pattern.
	LocalSymbols map[string]*PatternSymbol
}

type MatchPlan

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

func (MatchPlan) CaptureSymbolValues

func (plan MatchPlan) CaptureSymbolValues() map[string]interface{}

CaptureSymbolValues captures the current symbol values as nodes or []Edges

func (MatchPlan) GetCurrentPath

func (plan MatchPlan) GetCurrentPath() interface{}

GetCurrentPath returns the current path recoded in the stages of the pattern. The result is either a single node, or a path

func (MatchPlan) Run

func (plan MatchPlan) Run(graph Graph, symbols map[string]*PatternSymbol, result MatchAccumulator) error

type Node

type Node interface {
	GetGraph() Graph

	GetLabels() StringSet
	SetLabels(StringSet)

	GetProperty(string) (interface{}, bool)
	SetProperty(string, interface{})
	RemoveProperty(string)

	// Iterate properties until function returns false. Returns false if
	// function returns false, true if all properties are iterated (may be none)
	ForEachProperty(func(string, interface{}) bool) bool

	// Remove all connected edges, and remove the node
	DetachAndRemove()
	// Remove all connected edges
	Detach()

	// Returns an edge iterator for incoming or outgoing edges
	GetEdges(EdgeDir) EdgeIterator
	// Returns an edge iterator for incoming or outgoing edges with the given label
	GetEdgesWithLabel(EdgeDir, string) EdgeIterator
	// Returns an edge iterator for incoming or outgoingn edges that has the given labels
	GetEdgesWithAnyLabel(EdgeDir, StringSet) EdgeIterator
}

Node represents a graph node. A node is owned by a graph

func CopyNode

func CopyNode(sourceNode Node, target Graph, clonePropertyFunc func(string, interface{}) interface{}) Node

CopyNode copies the sourceNode into target graph

func NextNodesWith

func NextNodesWith(source Node, label string) []Node

NextNodesWith returns the nodes reachable from source with the given label at one step

func NodeSlice

func NodeSlice(in NodeIterator) []Node

NodeSlice reads all the remaining items of a node iterator and returns them in a slice

func PrevNodesWith

func PrevNodesWith(source Node, label string) []Node

PrevNodesWith returns the nodes reachable from source with the given label at one step

func SourceNodes

func SourceNodes(in EdgeIterator) []Node

SourceNodes returns the source nodes of all edges

func Sources

func Sources(graph Graph) []Node

Sources finds all the source nodes in the graph

func TargetNodes

func TargetNodes(in EdgeIterator) []Node

TargetNodes returns the target nodes of all edges

type NodeIterator

type NodeIterator interface {
	Iterator
	// Returns the current node
	Node() Node
}

NodeIterator iterates nodes of an underlying list

func SourcesItr

func SourcesItr(graph Graph) NodeIterator

Sources finds all the source nodes in the graph

type NodeMap

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

An NodeMap stores nodes indexed by node labels

func (*NodeMap) Add

func (nm *NodeMap) Add(node *OCNode)

func (NodeMap) IsEmpty

func (nm NodeMap) IsEmpty() bool

func (NodeMap) Iterator

func (nm NodeMap) Iterator() NodeIterator

func (NodeMap) IteratorAllLabels

func (nm NodeMap) IteratorAllLabels(labels StringSet) NodeIterator

func (NodeMap) Remove

func (nm NodeMap) Remove(node *OCNode)

type NodeSet

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

func (*NodeSet) Add

func (set *NodeSet) Add(node *OCNode)

func (NodeSet) Has

func (set NodeSet) Has(node *OCNode) bool

func (NodeSet) Iterator

func (set NodeSet) Iterator() NodeIterator

func (NodeSet) Len

func (set NodeSet) Len() int

func (NodeSet) Remove

func (set NodeSet) Remove(node *OCNode)

func (NodeSet) Slice

func (set NodeSet) Slice() []Node

type OCEdge

type OCEdge struct {
	Properties
	// contains filtered or unexported fields
}

func (*OCEdge) GetFrom

func (edge *OCEdge) GetFrom() Node

func (*OCEdge) GetGraph

func (edge *OCEdge) GetGraph() Graph

func (*OCEdge) GetLabel

func (edge *OCEdge) GetLabel() string

func (*OCEdge) GetTo

func (edge *OCEdge) GetTo() Node

func (*OCEdge) Remove

func (edge *OCEdge) Remove()

Remove an edge

func (*OCEdge) RemoveProperty

func (edge *OCEdge) RemoveProperty(key string)

func (*OCEdge) SetLabel

func (edge *OCEdge) SetLabel(label string)

func (*OCEdge) SetProperty

func (edge *OCEdge) SetProperty(key string, value interface{})

type OCGraph

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

func NewOCGraph

func NewOCGraph() *OCGraph

func (*OCGraph) AddEdgePropertyIndex

func (g *OCGraph) AddEdgePropertyIndex(propertyName string)

AddEdgePropertyIndex adds an index for the given edge property

func (*OCGraph) AddNodePropertyIndex

func (g *OCGraph) AddNodePropertyIndex(propertyName string)

AddNodePropertyIndex adds an index for the given node property

func (*OCGraph) DetachNode

func (g *OCGraph) DetachNode(node *OCNode)

func (*OCGraph) DetachRemoveNode

func (g *OCGraph) DetachRemoveNode(node *OCNode)

func (*OCGraph) FindEdges

func (g *OCGraph) FindEdges(labels StringSet, properties map[string]interface{}) EdgeIterator

FindEdges returns an iterator that will iterate through all the edges whose label is in the given labels and have all the properties. If labels is nil or empty, it does not look at the labels. If properties is nil or empty, it does not look at the properties

func (*OCGraph) FindNodes

func (g *OCGraph) FindNodes(allLabels StringSet, properties map[string]interface{}) NodeIterator

FindNodes returns an iterator that will iterate through all the nodes that have all of the given labels and properties. If allLabels is nil or empty, it does not look at the labels. If properties is nil or empty, it does not look at the properties

func (*OCGraph) GetEdges

func (g *OCGraph) GetEdges() EdgeIterator

func (*OCGraph) GetEdgesWithAnyLabel

func (g *OCGraph) GetEdgesWithAnyLabel(set StringSet) EdgeIterator

func (*OCGraph) GetEdgesWithProperty

func (g *OCGraph) GetEdgesWithProperty(property string) EdgeIterator

GetEdgesWithProperty returns an iterator for the edges that has the property

func (*OCGraph) GetNodeEdges

func (g *OCGraph) GetNodeEdges(node Node, dir EdgeDir) EdgeIterator

func (*OCGraph) GetNodeEdgesWithAnyLabel

func (g *OCGraph) GetNodeEdgesWithAnyLabel(node Node, dir EdgeDir, set StringSet) EdgeIterator

func (*OCGraph) GetNodeEdgesWithLabel

func (g *OCGraph) GetNodeEdgesWithLabel(node Node, dir EdgeDir, label string) EdgeIterator

func (*OCGraph) GetNodes

func (g *OCGraph) GetNodes() NodeIterator

func (*OCGraph) GetNodesWithAllLabels

func (g *OCGraph) GetNodesWithAllLabels(labels StringSet) NodeIterator

func (*OCGraph) GetNodesWithProperty

func (g *OCGraph) GetNodesWithProperty(property string) NodeIterator

GetNodesWithProperty returns an iterator for the nodes that has the property

func (*OCGraph) NewEdge

func (g *OCGraph) NewEdge(from, to Node, label string, properties map[string]interface{}) Edge

func (*OCGraph) NewNode

func (g *OCGraph) NewNode(labels []string, properties map[string]interface{}) Node

NewNode creates a new node with the given labels and properties

func (*OCGraph) NewOCNode

func (g *OCGraph) NewOCNode(labels []string, properties map[string]interface{}) *OCNode

NewOCNode creates a new node with the given labels and properties

func (*OCGraph) NumEdges

func (g *OCGraph) NumEdges() int

func (*OCGraph) NumNodes

func (g *OCGraph) NumNodes() int

func (*OCGraph) RemoveEdge

func (g *OCGraph) RemoveEdge(edge *OCEdge)

func (*OCGraph) RemoveEdgeProperty

func (g *OCGraph) RemoveEdgeProperty(edge *OCEdge, key string)

func (*OCGraph) RemoveNodeProperty

func (g *OCGraph) RemoveNodeProperty(node *OCNode, key string)

func (*OCGraph) SetEdgeLabel

func (g *OCGraph) SetEdgeLabel(edge *OCEdge, label string)

func (*OCGraph) SetEdgeProperty

func (g *OCGraph) SetEdgeProperty(edge *OCEdge, key string, value interface{})

func (*OCGraph) SetNodeLabels

func (g *OCGraph) SetNodeLabels(node *OCNode, labels StringSet)

func (*OCGraph) SetNodeProperty

func (g *OCGraph) SetNodeProperty(node *OCNode, key string, value interface{})

type OCNode

type OCNode struct {
	Properties
	// contains filtered or unexported fields
}

func (*OCNode) Detach

func (node *OCNode) Detach()

Remove all connected edges

func (*OCNode) DetachAndRemove

func (node *OCNode) DetachAndRemove()

Remove all connected edges, and remove the node

func (*OCNode) GetEdges

func (node *OCNode) GetEdges(dir EdgeDir) EdgeIterator

Returns an edge iterator for incoming or outgoing edges

func (*OCNode) GetEdgesWithAnyLabel

func (node *OCNode) GetEdgesWithAnyLabel(dir EdgeDir, labels StringSet) EdgeIterator

Returns an edge iterator for incoming or outgoingn edges that has the given labels

func (*OCNode) GetEdgesWithLabel

func (node *OCNode) GetEdgesWithLabel(dir EdgeDir, label string) EdgeIterator

Returns an edge iterator for incoming or outgoing edges with the given label

func (*OCNode) GetGraph

func (node *OCNode) GetGraph() Graph

func (*OCNode) GetLabels

func (node *OCNode) GetLabels() StringSet

func (*OCNode) RemoveProperty

func (node *OCNode) RemoveProperty(key string)

func (*OCNode) SetLabels

func (node *OCNode) SetLabels(labels StringSet)

func (*OCNode) SetProperty

func (node *OCNode) SetProperty(key string, value interface{})

func (OCNode) String

func (node OCNode) String() string

type OCStore

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

func NewOCStore

func NewOCStore() *OCStore

func (*OCStore) AddEdge

func (store *OCStore) AddEdge(edge *OCEdge)

func (*OCStore) AddNode

func (store *OCStore) AddNode(node *OCNode)

func (*OCStore) DetachNode

func (store *OCStore) DetachNode(node *OCNode)

func (*OCStore) DetachRemoveNode

func (store *OCStore) DetachRemoveNode(node *OCNode)

func (*OCStore) GetEdges

func (store *OCStore) GetEdges() EdgeIterator

func (*OCStore) GetEdgesWithAnyLabel

func (store *OCStore) GetEdgesWithAnyLabel(set StringSet) EdgeIterator

func (*OCStore) GetNodeEdges

func (store *OCStore) GetNodeEdges(node *OCNode, dir EdgeDir) EdgeIterator

func (*OCStore) GetNodeEdgesWithAnyLabel

func (store *OCStore) GetNodeEdgesWithAnyLabel(node *OCNode, dir EdgeDir, set StringSet) EdgeIterator

func (*OCStore) GetNodeEdgesWithLabel

func (store *OCStore) GetNodeEdgesWithLabel(node *OCNode, dir EdgeDir, label string) EdgeIterator

func (*OCStore) GetNodes

func (store *OCStore) GetNodes() NodeIterator

func (*OCStore) NumEdges

func (store *OCStore) NumEdges() int

func (*OCStore) NumNodes

func (store *OCStore) NumNodes() int

func (*OCStore) RemoveEdge

func (store *OCStore) RemoveEdge(edge *OCEdge)

type Pattern

type Pattern []PatternItem

Pattern contains pattern items, with even numbered elements corresponding to nodes, and odd numbered elements corresponding to edges

func (Pattern) FindNodes

func (pattern Pattern) FindNodes(graph Graph, symbols map[string]*PatternSymbol) ([]Node, error)

FindNodes runs the pattern with the given symbols, and returns all the head nodes found

func (Pattern) GetPlan

func (pattern Pattern) GetPlan(graph Graph, symbols map[string]*PatternSymbol) (MatchPlan, error)

GetPlan returns a match execution plan

func (Pattern) GetSymbolNames

func (pattern Pattern) GetSymbolNames() StringSet

func (Pattern) Run

func (pattern Pattern) Run(graph Graph, symbols map[string]*PatternSymbol, result MatchAccumulator) error

type PatternItem

type PatternItem struct {
	Labels     StringSet
	Properties map[string]interface{}
	Min        int
	Max        int
	Backwards  bool
	// Name of the variable associated with this processing node. If the
	// name is defined, it is used to constrain values. If not, it is
	// used to store values
	Name string
}

A PatternItem can be a node or an edge element of a pattern

type PatternSymbol

type PatternSymbol struct {
	Nodes *NodeSet
	Edges *EdgeSet
}

A PatternSymbol contains either nodes, or edges.

func (*PatternSymbol) Add

func (p *PatternSymbol) Add(item interface{}) bool

func (*PatternSymbol) AddNode

func (p *PatternSymbol) AddNode(item Node)

func (*PatternSymbol) AddPath

func (p *PatternSymbol) AddPath(path []Edge)

func (*PatternSymbol) EdgeSlice

func (p *PatternSymbol) EdgeSlice() []Edge

func (*PatternSymbol) NodeSlice

func (p *PatternSymbol) NodeSlice() []Node

type Properties

type Properties map[string]interface{}

func (*Properties) ForEachProperty

func (p *Properties) ForEachProperty(f func(string, interface{}) bool) bool

ForEachProperty calls f for each property in p until f returns false. Returns false if f returned false. p can be nil

func (*Properties) GetProperty

func (p *Properties) GetProperty(key string) (interface{}, bool)

GetProperty returns the value for the key, and whether or not key exists. p can be nil

func (Properties) String

func (p Properties) String() string

type Store

type Store interface {
	AddNode(node *OCNode)
	DetachNode(node *OCNode)
	DetachRemoveNode(node *OCNode)
	AddEdge(edge *OCEdge)
	RemoveEdge(edge *OCEdge)
	GetNodeEdges(node *OCNode, dir EdgeDir) EdgeIterator
	GetNodeEdgesWithLabel(node *OCNode, dir EdgeDir, label string) EdgeIterator
	GetNodeEdgesWithAnyLabel(node *OCNode, dir EdgeDir, set StringSet) EdgeIterator
	NumNodes() int
	GetNodes() NodeIterator
	GetEdges() EdgeIterator
	NumEdges() int
	GetEdgesWithAnyLabel(set StringSet) EdgeIterator
}

Store keeps the nodes, edges, and the connections of a graph

type StringSet

type StringSet map[string]struct{}

func NewStringSet

func NewStringSet(s ...string) StringSet

func (StringSet) Add

func (set StringSet) Add(s ...string) StringSet

func (StringSet) AddSet

func (set StringSet) AddSet(s StringSet) StringSet

func (StringSet) Has

func (set StringSet) Has(s string) bool

func (StringSet) HasAll

func (set StringSet) HasAll(s ...string) bool

func (StringSet) HasAllSet

func (set StringSet) HasAllSet(s StringSet) bool

func (StringSet) HasAny

func (set StringSet) HasAny(s ...string) bool

func (StringSet) HasAnySet

func (set StringSet) HasAnySet(s StringSet) bool

func (StringSet) IsEqual

func (set StringSet) IsEqual(s StringSet) bool

func (StringSet) Remove

func (set StringSet) Remove(s ...string) StringSet

func (StringSet) Slice

func (set StringSet) Slice() []string

func (StringSet) SortedSlice

func (set StringSet) SortedSlice() []string

func (StringSet) String

func (set StringSet) String() string

type VPathIterator

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

func GetVPathIterator

func GetVPathIterator(graph Graph, firstLeg EdgeIterator, edgeFilter func(Edge) bool, dir EdgeDir, min, max int) *VPathIterator

func (*VPathIterator) AddPath

func (v *VPathIterator) AddPath(path []Edge) bool

func (*VPathIterator) Next

func (v *VPathIterator) Next() bool

func (*VPathIterator) Path

func (v *VPathIterator) Path() []Edge

type WithProperties

type WithProperties interface {
	GetProperty(key string) (interface{}, bool)
}

Jump to

Keyboard shortcuts

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