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.
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.
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.
Index ¶
- func CheckIsomorphism(g1, g2 Graph, nodeEquivalenceFunc func(n1, n2 Node) bool, ...) bool
- func CollectAllPaths(graph Graph, fromNode Node, firstLeg EdgeIterator, edgeFilter func(Edge) bool, ...)
- func ComparePropertyValue(a, b interface{}) int
- func CopyGraph(source, target Graph, clonePropertyFunc func(string, interface{}) interface{}) map[Node]Node
- func CopyGraphf(source Graph, copyNodeFunc func(Node, map[Node]Node) Node, ...) map[Node]Node
- func CopySubgraph(sourceNode Node, target Graph, ...)
- func DefaultDOTEdgeRender(fromNode, toNode string, edge Edge, w io.Writer) error
- func DefaultDOTNodeRender(ID string, node Node, w io.Writer) error
- func ForEachNode(g Graph, predicate func(Node) bool) bool
- func GetEdgeFilterFunc(labels StringSet, properties map[string]interface{}) func(Edge) bool
- func GetNodeFilterFunc(labels StringSet, properties map[string]interface{}) func(Node) bool
- type DOTRenderer
- func (d DOTRenderer) Render(g Graph, graphName string, out io.Writer) error
- func (d DOTRenderer) RenderEdge(fromID, toID string, edge Edge, w io.Writer) (bool, error)
- func (d DOTRenderer) RenderNode(ID string, node Node, w io.Writer) (bool, error)
- func (d DOTRenderer) RenderNodesEdges(g Graph, out io.Writer) error
- type DefaultMatchAccumulator
- type Edge
- type EdgeDir
- type EdgeIterator
- type EdgeMap
- func (em *EdgeMap) Add(edge *OCEdge)
- func (em *EdgeMap) Clear()
- func (em EdgeMap) IsEmpty() bool
- func (em EdgeMap) Iterator() EdgeIterator
- func (em EdgeMap) IteratorAnyLabel(labels StringSet) EdgeIterator
- func (em EdgeMap) IteratorLabel(label string) EdgeIterator
- func (em EdgeMap) Len() int
- func (em EdgeMap) Remove(edge *OCEdge)
- type EdgeSet
- type ErrEdgeVariableExpected
- type ErrInvalidGraph
- type ErrNodeVariableExpected
- type FastSet
- type Graph
- type Interner
- type Iterator
- type JSON
- type MapInterner
- type MatchAccumulator
- type MatchContext
- type MatchPlan
- type Node
- func CopyNode(sourceNode Node, target Graph, ...) Node
- func NextNodesWith(source Node, label string) []Node
- func NodeSlice(in NodeIterator) []Node
- func PrevNodesWith(source Node, label string) []Node
- func SourceNodes(in EdgeIterator) []Node
- func Sources(graph Graph) []Node
- func TargetNodes(in EdgeIterator) []Node
- type NodeIterator
- type NodeMap
- type NodeSet
- type OCEdge
- func (edge *OCEdge) GetFrom() Node
- func (edge *OCEdge) GetGraph() Graph
- func (edge *OCEdge) GetID() int
- func (edge *OCEdge) GetLabel() string
- func (edge *OCEdge) GetTo() Node
- func (edge *OCEdge) Remove()
- func (edge *OCEdge) RemoveProperty(key string)
- func (edge *OCEdge) SetLabel(label string)
- func (edge *OCEdge) SetProperty(key string, value interface{})
- func (edge *OCEdge) String() string
- type OCGraph
- func (g *OCGraph) AddEdgePropertyIndex(propertyName string)
- func (g *OCGraph) AddNodePropertyIndex(propertyName string)
- func (g *OCGraph) DetachNode(node *OCNode)
- func (g *OCGraph) DetachRemoveNode(node *OCNode)
- func (g *OCGraph) FindEdges(labels StringSet, properties map[string]interface{}) EdgeIterator
- func (g *OCGraph) FindNodes(allLabels StringSet, properties map[string]interface{}) NodeIterator
- func (g *OCGraph) GetEdges() EdgeIterator
- func (g *OCGraph) GetEdgesWithAnyLabel(set StringSet) EdgeIterator
- func (g *OCGraph) GetEdgesWithProperty(property string) EdgeIterator
- func (g *OCGraph) GetNodes() NodeIterator
- func (g *OCGraph) GetNodesWithAllLabels(labels StringSet) NodeIterator
- func (g *OCGraph) GetNodesWithProperty(property string) NodeIterator
- func (g *OCGraph) NewEdge(from, to Node, label string, properties map[string]interface{}) Edge
- func (g *OCGraph) NewNode(labels []string, properties map[string]interface{}) Node
- func (g *OCGraph) NewOCNode(labels []string, properties map[string]interface{}) *OCNode
- func (g *OCGraph) NumEdges() int
- func (g *OCGraph) NumNodes() int
- func (g *OCGraph) RemoveEdge(edge *OCEdge)
- func (g *OCGraph) RemoveEdgeProperty(edge *OCEdge, key string)
- func (g *OCGraph) RemoveNodeProperty(node *OCNode, key string)
- func (g *OCGraph) SetEdgeLabel(edge *OCEdge, label string)
- func (g *OCGraph) SetEdgeProperty(edge *OCEdge, key string, value interface{})
- func (g *OCGraph) SetNodeLabels(node *OCNode, labels StringSet)
- func (g *OCGraph) SetNodeProperty(node *OCNode, key string, value interface{})
- type OCNode
- func (node *OCNode) Detach()
- func (node *OCNode) DetachAndRemove()
- func (node *OCNode) GetEdges(dir EdgeDir) EdgeIterator
- func (node *OCNode) GetEdgesWithAnyLabel(dir EdgeDir, labels StringSet) EdgeIterator
- func (node *OCNode) GetEdgesWithLabel(dir EdgeDir, label string) EdgeIterator
- func (node *OCNode) GetGraph() Graph
- func (node *OCNode) GetID() int
- func (node *OCNode) GetLabels() StringSet
- func (node *OCNode) HasLabel(s string) bool
- func (node *OCNode) RemoveProperty(key string)
- func (node *OCNode) SetLabels(labels StringSet)
- func (node *OCNode) SetProperty(key string, value interface{})
- func (node OCNode) String() string
- type Pattern
- func (pattern Pattern) FindNodes(graph Graph, symbols map[string]*PatternSymbol) ([]Node, error)
- func (pattern Pattern) FindPaths(graph Graph, symbols map[string]*PatternSymbol) (DefaultMatchAccumulator, error)
- func (pattern Pattern) GetPlan(graph Graph, symbols map[string]*PatternSymbol) (MatchPlan, error)
- func (pattern Pattern) GetSymbolNames() StringSet
- func (pattern Pattern) Run(graph Graph, symbols map[string]*PatternSymbol, result MatchAccumulator) error
- type PatternItem
- type PatternSymbol
- type Properties
- type StringSet
- func (set *StringSet) Add(s ...string) *StringSet
- func (set *StringSet) AddSet(s StringSet) *StringSet
- func (set StringSet) Clone() StringSet
- func (set StringSet) Has(s string) bool
- func (set StringSet) HasAll(s ...string) bool
- func (set StringSet) HasAllSet(s StringSet) bool
- func (set StringSet) HasAny(s ...string) bool
- func (set StringSet) HasAnySet(s StringSet) bool
- func (set StringSet) IsEqual(s StringSet) bool
- func (set StringSet) Len() int
- func (set StringSet) MarshalJSON() ([]byte, error)
- func (set *StringSet) Remove(s ...string) *StringSet
- func (set StringSet) Slice() []string
- func (set StringSet) SortedSlice() []string
- func (set StringSet) String() string
- func (set *StringSet) UnmarshalJSON(in []byte) error
- type WithProperties
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 all pairs of nodes. The edgeEquivalenceFunction will be called for edges connecting equivalent nodes.
func CollectAllPaths ¶
func CollectAllPaths(graph Graph, fromNode Node, firstLeg EdgeIterator, edgeFilter func(Edge) bool, dir EdgeDir, min, max int, accumulator func([]Edge, Node) 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 must be comparable. 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 ¶
DefaultDOTEdgeRender renders the edge with a label if there is one, or without a label if there is not a label.
func DefaultDOTNodeRender ¶
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 ¶
ForEachNode iterates through all the nodes of g until predicate returns false or all nodes are processed.
func GetEdgeFilterFunc ¶
GetEdgeFilterFunc returns a function that can be used to pass edges that have at least one of the specified labels, with correct property values
Types ¶
type DOTRenderer ¶
type DOTRenderer struct {
// NodeRenderer renders 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) RenderEdge ¶
RenderEdge renders an edge. If edge renderer is not set, call the default rendeded
func (DOTRenderer) RenderNode ¶
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) GetTailNodes ¶
func (acc *DefaultMatchAccumulator) GetTailNodes() []Node
Returns the unique nodes in the accumulator that ends 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 EdgeIterator ¶
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) 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
type EdgeSet ¶
type EdgeSet struct {
// contains filtered or unexported fields
}
EdgeSet keeps an unordered set of edges
func (EdgeSet) Iterator ¶
func (set EdgeSet) Iterator() EdgeIterator
type ErrEdgeVariableExpected ¶
type ErrEdgeVariableExpected string
func (ErrEdgeVariableExpected) Error ¶
func (e ErrEdgeVariableExpected) Error() string
type ErrInvalidGraph ¶
type ErrInvalidGraph struct {
Msg string
}
func (ErrInvalidGraph) Error ¶
func (e ErrInvalidGraph) 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
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 Interner ¶
type Interner interface {
// Intern should return the interned copy of the string
Intern(string) string
}
Interner is a string interface, that can be as simple as a map[string]string, that is used to intern property keys
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 ¶
MultiIterator returns an iterator that contatenates all the given iterators
type JSON ¶
type JSON struct {
Interner Interner
// If false, dring marshaling edges are embedded in the source
// nodes. If true, edges are marshaled separately as a JSON array.
MarshalEdgesSeparately bool
// PropertyUnmarshaler unmarshals a property value. The return
// values are the key, value, and possible error. If the returned
// key is empty, the property is not unmarshaled. If this is nil,
// default json unmarshaler is used for property value.
PropertyUnmarshaler func(key string, value json.RawMessage) (string, interface{}, error)
// PropertyMarshaler marshals a property value. The return values
// are the key, the marshaled value, and possible error. If the
// returned key is empty, the property is not marshaled. If this is
// nil, the default json marshaler is used for property value.
PropertyMarshaler func(key string, value interface{}) (string, json.RawMessage, error)
}
JSON marshals/unmarshals a graph to/from JSON.
The JSON unmarshaling uses a string Interner if it is set. This allows reusing the strings for repeated keys. Setting this interner to an implementation will reduce memory footprint of the graph. If letf uninitialized, the unmarshaler still uses an interner, but this interner will not be shared between different graphs unmarshaled using this unmarshaler.
If PropertyMarshaler/PropertyUnmarshaler is set, these functions are called to marshal/unmarshal individual properties. These function can return an empty string for the key to skip the property.
If MarshalEdgesSeparately is set, graph edges are marshaled under the "edges" key. If this is false, the graph edges are included under the source node.
The JSON representation of nodes use a numeric node index. These indexes are used to refer to nodes in edges.
With MarshalEdgesSeparately=false:
{
"nodes": [
{
"n": 0,
"labels": ["lbl1","lbl2"],
"properties": {
"key": "value"
},
"edges": [
{
"to": 1,
"label": "edgeLabel"
}
]
},
{
"n": 1,
"labels": ["lbl1"]
}
]
}
With MarshalEdgesSeparately=true:
{
"nodes": [
{
"n": 0,
"labels": ["lbl1","lbl2"],
"properties": {
"key": "value"
}
},
{
"n": 1,
"labels": ["lbl1"]
}
],
"edges": [
{
"from": 0,
"to": 1,
"label": "edgeLabel"
}
]
}
type MapInterner ¶
MapInterner is a basic interner that uses a map[string]string to intern strings
func (MapInterner) Intern ¶
func (i MapInterner) Intern(s string) string
Intern keeps the interned copy of s in the map
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
// contains filtered or unexported fields
}
type MatchPlan ¶
type MatchPlan struct {
// contains filtered or unexported fields
}
func (MatchPlan) CaptureSymbolValues ¶
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)
HasLabel(string) bool
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 ¶
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 ¶
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 TargetNodes ¶
func TargetNodes(in EdgeIterator) []Node
TargetNodes returns the target nodes of all edges
type NodeIterator ¶
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) Iterator ¶
func (nm NodeMap) Iterator() NodeIterator
func (NodeMap) IteratorAllLabels ¶
func (nm NodeMap) IteratorAllLabels(labels StringSet) NodeIterator
type NodeSet ¶
type NodeSet struct {
// contains filtered or unexported fields
}
func (NodeSet) Iterator ¶
func (set NodeSet) Iterator() NodeIterator
type OCEdge ¶
type OCEdge struct {
Properties
// contains filtered or unexported fields
}
func (*OCEdge) RemoveProperty ¶
func (*OCEdge) SetProperty ¶
type OCGraph ¶
type OCGraph struct {
// contains filtered or unexported fields
}
func NewOCGraph ¶
func NewOCGraph() *OCGraph
func (*OCGraph) AddEdgePropertyIndex ¶
AddEdgePropertyIndex adds an index for the given edge property
func (*OCGraph) AddNodePropertyIndex ¶
AddNodePropertyIndex adds an index for the given node property
func (*OCGraph) DetachNode ¶
func (*OCGraph) DetachRemoveNode ¶
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) 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) RemoveEdge ¶
func (*OCGraph) RemoveEdgeProperty ¶
func (*OCGraph) RemoveNodeProperty ¶
func (*OCGraph) SetEdgeLabel ¶
func (*OCGraph) SetEdgeProperty ¶
func (*OCGraph) SetNodeLabels ¶
func (*OCGraph) SetNodeProperty ¶
type OCNode ¶
type OCNode struct {
Properties
// contains filtered or unexported fields
}
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) RemoveProperty ¶
func (*OCNode) SetProperty ¶
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 ¶
FindNodes runs the pattern with the given symbols, and returns all the head nodes found
func (Pattern) FindPaths ¶
func (pattern Pattern) FindPaths(graph Graph, symbols map[string]*PatternSymbol) (DefaultMatchAccumulator, error)
func (Pattern) GetSymbolNames ¶
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=-1 and Max=-1 for variable length
Min int
Max int
// ToLeft is true if this is a relationship of the form <-
ToLeft bool
// Undirected is true if this is a relationship of the form --
Undirected 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 ¶
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 StringSet ¶
type StringSet struct {
M map[string]struct{}
}