Documentation ¶
Index ¶
- func CheckIsomorphism(ctx context.Context, g1, g2 *Graph, ...) (bool, error)
- func CollectAllPaths(graph *Graph, fromNode *Node, firstLeg EdgeIterator, ...)
- 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 Cursor
- func (c *Cursor) Backward() EdgeIterator
- func (c *Cursor) BackwardWith(label string) EdgeIterator
- func (c *Cursor) Edges(dir EdgeDir) EdgeIterator
- func (c *Cursor) EdgesWith(dir EdgeDir, label string) EdgeIterator
- func (c *Cursor) Forward() EdgeIterator
- func (c *Cursor) ForwardWith(label string) EdgeIterator
- func (c *Cursor) GetPath() *Path
- func (c *Cursor) NextNodes() NodeIterator
- func (c *Cursor) NextNodesWith(label string) NodeIterator
- func (c *Cursor) Nodes(dir EdgeDir) NodeIterator
- func (c *Cursor) NodesWith(dir EdgeDir, label string) NodeIterator
- func (c *Cursor) PopFromPath() *Cursor
- func (c *Cursor) PrevNodes() NodeIterator
- func (c *Cursor) PrevNodesWith(label string) NodeIterator
- func (c *Cursor) PushToPath(edge *Edge) *Cursor
- func (c *Cursor) Set(node *Node) *Cursor
- func (c *Cursor) StartPath() *Cursor
- 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
- func (edge *Edge) ForEachProperty(f func(string, interface{}) bool) bool
- func (edge *Edge) GetContexts() *StringSet
- func (edge *Edge) GetFrom() *Node
- func (edge *Edge) GetGraph() *Graph
- func (edge *Edge) GetID() int
- func (edge *Edge) GetLabel() string
- func (edge *Edge) GetProperty(key string) (interface{}, bool)
- func (edge *Edge) GetTo() *Node
- func (edge *Edge) HasAllContexts(context ...string) bool
- func (edge *Edge) HasAllContextsSet(contexts *StringSet) bool
- func (edge *Edge) HasAnyContext(contexts ...string) bool
- func (edge *Edge) HasAnyContextsSet(contexts *StringSet) bool
- func (edge *Edge) Remove()
- func (edge *Edge) RemoveProperty(key string)
- func (edge *Edge) SetContexts(contexts *StringSet)
- func (edge *Edge) SetLabel(label string)
- func (edge *Edge) SetProperty(key string, value interface{})
- func (edge *Edge) String() string
- type EdgeDir
- type EdgeIterator
- type EdgeSet
- type ErrEdgeVariableExpected
- type ErrNodeVariableExpected
- type Graph
- func (g *Graph) AddEdgePropertyIndex(propertyName string, ix IndexType)
- func (g *Graph) AddNodePropertyIndex(propertyName string, ix IndexType)
- func (g *Graph) FastNewEdge(from, to *Node, label string, props map[string]any, contexts *StringSet) *Edge
- func (g *Graph) FastNewNode(labels *StringSet, props map[string]interface{}, contexts *StringSet) *Node
- func (g *Graph) FindEdges(label string, properties map[string]interface{}) (EdgeIterator, error)
- func (g *Graph) FindNodes(allLabels *StringSet, properties map[string]interface{}) (NodeIterator, error)
- func (g *Graph) GetEdges() EdgeIterator
- func (g *Graph) GetEdgesWithAnyLabel(set *StringSet) EdgeIterator
- func (g *Graph) GetEdgesWithProperty(property string) EdgeIterator
- func (g *Graph) GetNodes() NodeIterator
- func (g *Graph) GetNodesWithAllLabels(labels *StringSet) NodeIterator
- func (g *Graph) GetNodesWithProperty(property string) NodeIterator
- func (g *Graph) NewEdge(from, to *Node, label string, props map[string]any, contexts *StringSet) *Edge
- func (g *Graph) NewNode(labels []string, props map[string]interface{}, contexts *StringSet) *Node
- func (g *Graph) NumEdges() int
- func (g *Graph) NumNodes() int
- func (g *Graph) ProcessEdgesWithAnyContext(nodeId int, contexts *StringSet, dir EdgeDir, handler func(*Edge))
- func (g *Graph) ProcessNodeWithAnyContext(contexts *StringSet, handler func(*Node))
- type IndexType
- type Item
- type Iterator
- 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 Sinks(graph *Graph) []*Node
- func SourceNodes(in EdgeIterator) []*Node
- func Sources(graph *Graph) []*Node
- func TargetNodes(in EdgeIterator) []*Node
- func (node *Node) Detach()
- func (node *Node) DetachAndRemove()
- func (node *Node) ForEachProperty(f func(string, interface{}) bool) bool
- func (node *Node) GetContexts() *StringSet
- func (node *Node) GetEdges(dir EdgeDir) EdgeIterator
- func (node *Node) GetEdgesWithAnyLabel(dir EdgeDir, labels *StringSet) EdgeIterator
- func (node *Node) GetEdgesWithLabel(dir EdgeDir, label string) EdgeIterator
- func (node *Node) GetGraph() *Graph
- func (node *Node) GetID() int
- func (node *Node) GetLabels() *StringSet
- func (node *Node) GetNLabels(n int) *StringSet
- func (node *Node) GetProperty(key string) (interface{}, bool)
- func (node *Node) HasAllContext(context ...string) bool
- func (node *Node) HasAllContextsSet(contexts *StringSet) bool
- func (node *Node) HasAllLabels(labels ...string) bool
- func (node *Node) HasAnyContext(contexts ...string) bool
- func (node *Node) HasAnyContextsSet(contexts *StringSet) bool
- func (node *Node) HasAnyLabel(labels ...string) bool
- func (node *Node) HasLabel(s string) bool
- func (node *Node) IncomingEdgeCount() int
- func (node *Node) OutgoingEdgeCount() int
- func (node *Node) RemoveProperty(key string)
- func (node *Node) SetContexts(contexts *StringSet)
- func (node *Node) SetLabels(labels *StringSet)
- func (node *Node) SetProperty(key string, value interface{})
- func (node *Node) String() string
- type NodeIterator
- type NodeMap
- type NodeSet
- type Path
- func (p *Path) Append(path ...PathElement) *Path
- func (p *Path) AppendPath(path *Path) *Path
- func (p *Path) Clear() *Path
- func (p *Path) Clone() *Path
- func (p *Path) First() *Node
- func (p *Path) GetEdge(n int) *Edge
- func (p *Path) GetNode(n int) *Node
- func (p *Path) HasPrefix(p1 []PathElement) bool
- func (p *Path) HasPrefixPath(p1 *Path) bool
- func (p *Path) IsEmpty() bool
- func (p *Path) Last() *Node
- func (p *Path) NumEdges() int
- func (p *Path) NumNodes() int
- func (p *Path) RemoveFirst() *Path
- func (p *Path) RemoveLast() *Path
- func (p *Path) SetOnlyNode(node *Node) *Path
- func (p *Path) Slice(startNodeIndex, endNodeIndex int) *Path
- func (p *Path) String() string
- type PathElement
- 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 StringSet
- func (set *StringSet) Add(s ...string) *StringSet
- func (set *StringSet) AddSet(s StringSet) *StringSet
- func (set *StringSet) Clone() *StringSet
- func (set *StringSet) CloneN(n int) *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) Intersect(s *StringSet) *StringSet
- func (set *StringSet) IsEqual(s *StringSet) bool
- func (set *StringSet) Iter(f func(string) bool)
- func (f *StringSet) Iterator() Iterator
- func (set *StringSet) Len() int
- func (f *StringSet) Range() iter.Seq[string]
- func (set *StringSet) Remove(s ...string) *StringSet
- func (set *StringSet) Replace(other *StringSet, handleRemoved, handleAdded func(string))
- func (set *StringSet) Slice() []string
- func (set *StringSet) SortedSlice() []string
- func (set *StringSet) String() string
- type WithNativeValue
- type WithProperties
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckIsomorphism ¶
func CheckIsomorphism(ctx context.Context, g1, g2 *Graph, nodeEquivalenceFunc func(n1, n2 *Node) bool, edgeEquivalenceFunc func(e1, e2 *Edge) bool) (bool, error)
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.
This is a potentially long running function. Cancel the context to stop. If the function returns because of context cancellation, error will be ctx.Err()
func CollectAllPaths ¶
func CollectAllPaths(graph *Graph, fromNode *Node, firstLeg EdgeIterator, edgeFilter func(*Edge) bool, dir EdgeDir, min, max int, accumulator func(*Path) 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 select edges that have at least one of the specified labels, with correct property values
Types ¶
type Cursor ¶
type Cursor struct {
// contains filtered or unexported fields
}
Cursor is a convenience class to move around a graph
func (*Cursor) Backward ¶
func (c *Cursor) Backward() EdgeIterator
Backward returns an edge iterator for incoming edges of the current node. If the current node is invalid, returns an empty iterator
func (*Cursor) BackwardWith ¶
func (c *Cursor) BackwardWith(label string) EdgeIterator
BackwardWith returns an edge iterator for incoming edges of the current node with the given label. If the current node is invalid, returns an empty iterator
func (*Cursor) Edges ¶
func (c *Cursor) Edges(dir EdgeDir) EdgeIterator
Edges returns an iterator of edges of the current node. If the current node is invalid, returns an empty iterator
func (*Cursor) EdgesWith ¶
func (c *Cursor) EdgesWith(dir EdgeDir, label string) EdgeIterator
EdgesWith returns an iterator of edges of the current node with the given label. If the current node is invalid, returns an empty iterator
func (*Cursor) Forward ¶
func (c *Cursor) Forward() EdgeIterator
Forward returns an edge iterator for outgoing edges of the current node. If the current node is invalid, returns an empty iterator
func (*Cursor) ForwardWith ¶
func (c *Cursor) ForwardWith(label string) EdgeIterator
ForwardWith returns an edge iterator for outgoing edges of the current node with the given label. If the current node is invalid, returns an empty iterator
func (*Cursor) GetPath ¶
GetPath returns the recorded path. This is the internal copy of the path, so caller must clone if it changes are necessary
func (*Cursor) NextNodes ¶
func (c *Cursor) NextNodes() NodeIterator
NextNodes returns a node iterator that can be reached at one step from the current node. If current node is invalid, returns an empty iterator.
func (*Cursor) NextNodesWith ¶
func (c *Cursor) NextNodesWith(label string) NodeIterator
NextNodesWith returns a node iterator that can be reached at one step from the current node with the given label. If current node is invalid, returns an empty iterator.
func (*Cursor) Nodes ¶
func (c *Cursor) Nodes(dir EdgeDir) NodeIterator
Nodes returns an iterator over the nodes that are reachable by a single edge from the current node. If the current node is not valid, returns an empty iterator
func (*Cursor) NodesWith ¶
func (c *Cursor) NodesWith(dir EdgeDir, label string) NodeIterator
NodesWith returns an iterator over the nodes that are reachable by a single edge with the given label from the current node. If the current node is not valid, returns an empty iterator
func (*Cursor) PopFromPath ¶
PopFromPath removes the last edge from the path. This also moves the cursor to the previous node
func (*Cursor) PrevNodes ¶
func (c *Cursor) PrevNodes() NodeIterator
PrevNodes returns a node iterator that can be reached at one step backwards from the current node. If current node is invalid, returns an empty iterator.
func (*Cursor) PrevNodesWith ¶
func (c *Cursor) PrevNodesWith(label string) NodeIterator
PrevNodesWith returns a node iterator that can be reached at one step backwards from the current node with the given label. If current node is invalid, returns an empty iterator.
func (*Cursor) PushToPath ¶
PushToPath pushes the edge onto the path. The path must be started, and the pushed edge must be connected to the current node. This also advances the cursor to the target node.
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 []*Path 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 *Path, symbols map[string]interface{})
type Edge ¶
type Edge struct {
// contains filtered or unexported fields
}
An Edge connects two nodes of a graph
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
func EdgesBetweenNodes ¶
EdgesBetweenNodes finds all the edges that go from 'from' to 'to'
func (*Edge) ForEachProperty ¶
func (*Edge) GetContexts ¶ added in v3.0.5
func (*Edge) GetID ¶
GetID returns the unique identifier for the edge. The identifier is unique in this graph, and meaningless once the edge is disconnected.
func (*Edge) GetProperty ¶
write public func for GetProperty, ForEachProperty
func (*Edge) HasAllContexts ¶ added in v3.0.5
func (*Edge) HasAllContextsSet ¶ added in v3.0.12
func (*Edge) HasAnyContext ¶ added in v3.0.4
func (*Edge) HasAnyContextsSet ¶ added in v3.0.12
func (*Edge) RemoveProperty ¶
RemoveProperty removes an edge property
func (*Edge) SetContexts ¶ added in v3.0.4
func (*Edge) SetProperty ¶
SetProperty sets an edge property
type EdgeIterator ¶
EdgeIterator iterates the edges of an underlying list
type EdgeSet ¶
type EdgeSet struct {
// contains filtered or unexported fields
}
EdgeSet keeps an unordered set of edges
func NewEdgeSet ¶
func NewEdgeSet() *EdgeSet
func (*EdgeSet) Iterator ¶
func (set *EdgeSet) Iterator() EdgeIterator
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 Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
A Graph is a labeled property graph containing nodes, and directed edges combining those nodes.
Every node of the graph contains a set of labels, and a map of properties. Each node provides access to the edges adjacent to it. Every edge contains a from and to node, a label, and a map of properties.
Nodes and edges are "owned" by a graph object. Given a node or edge, you can always get its graph using `node.GetGraph()` or `edge.GetGraph()` method. You cannot use an edge to connect nodes of different graphs.
Zero value for a Graph is not usable. Use `NewGraph` to construct a new graph.
func NewGraph ¶
func NewGraph() *Graph
NewGraph constructs and returns a new graph. The new graph has no nodes or edges.
func (*Graph) AddEdgePropertyIndex ¶
AddEdgePropertyIndex adds an index for the given edge property
func (*Graph) AddNodePropertyIndex ¶
AddNodePropertyIndex adds an index for the given node property
func (*Graph) FastNewEdge ¶
func (g *Graph) FastNewEdge(from, to *Node, label string, props map[string]any, contexts *StringSet) *Edge
FastNewEdge creates a new edge between the two nodes of the graph. Both nodes must be nodes of this graph, otherwise this call panics. This version uses the given properties map directly without copying it.
func (*Graph) FastNewNode ¶
func (g *Graph) FastNewNode(labels *StringSet, props map[string]interface{}, contexts *StringSet) *Node
FastNewNode creates a new node with the given labels and properties. This version does not copy the labels and properties, but uses the given label set and map directly
func (*Graph) FindEdges ¶
func (g *Graph) FindEdges(label string, properties map[string]interface{}) (EdgeIterator, error)
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 it can only find a single label since edges only have one label so multiple ones will always return empty
func (*Graph) FindNodes ¶
func (g *Graph) FindNodes(allLabels *StringSet, properties map[string]interface{}) (NodeIterator, error)
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 (*Graph) GetEdges ¶
func (g *Graph) GetEdges() EdgeIterator
GetEdges returns an edge iterator that goes through all the edges of the graph. The behavior of the returned iterator is undefined if during iteration edges are updated, new edges are added, or existing edges are deleted.
func (*Graph) GetEdgesWithAnyLabel ¶
func (g *Graph) GetEdgesWithAnyLabel(set *StringSet) EdgeIterator
GetEdgesWithAnyLabel returns an iterator that goes through the edges of the graph that are labeled with one of the labels in the given set. The behavior of the returned iterator is undefined if during iteration edges are updated, new edges are added, or existing edges are deleted.
func (*Graph) GetEdgesWithProperty ¶
func (g *Graph) GetEdgesWithProperty(property string) EdgeIterator
GetEdgesWithProperty returns an iterator for the edges that has the property. If there is an index for the property, and iterator over that index is returned. Otherwise, an iterator that goes through all edges while filtering them is returned. The behavior of the returned iterator is undefined if during iteration edges are updated, new edges are added, or existing edges are deleted.
func (*Graph) GetNodes ¶
func (g *Graph) GetNodes() NodeIterator
GetNodes returns a node iterator that goes through all the nodes of the graph. The behavior of the returned iterator is undefined if during iteration nodes are updated, new nodes are added, or existing nodes are deleted.
func (*Graph) GetNodesWithAllLabels ¶
func (g *Graph) GetNodesWithAllLabels(labels *StringSet) NodeIterator
GetNodesWithAllLabels returns an iterator that goes through the nodes that have all the nodes given in the set. The nodes may have more nodes than given in the set. The behavior of the returned iterator is undefined if during iteration nodes are updated, new nodes are added, or existing nodes are deleted.
func (*Graph) GetNodesWithProperty ¶
func (g *Graph) GetNodesWithProperty(property string) NodeIterator
GetNodesWithProperty returns an iterator for the nodes that has the property. If there is an index for the node property, and iterator over that index is returned. Otherwise, an iterator that goes through all nodes while filtering them is returned. The behavior of the returned iterator is undefined if during iteration nodes are updated, new nodes are added, or existing nodes are deleted.
func (*Graph) NewEdge ¶
func (g *Graph) NewEdge(from, to *Node, label string, props map[string]any, contexts *StringSet) *Edge
NewEdge creates a new edge between the two nodes of the graph. Both nodes must be nodes of this graph, otherwise this call panics
func (*Graph) ProcessEdgesWithAnyContext ¶ added in v3.0.4
func (*Graph) ProcessNodeWithAnyContext ¶ added in v3.0.7
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 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 *Path, 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 ¶
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 struct {
// contains filtered or unexported fields
}
A Node represents a graph node.
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
func (*Node) DetachAndRemove ¶
func (node *Node) DetachAndRemove()
Remove all connected edges, and remove the node
func (*Node) ForEachProperty ¶
func (*Node) GetContexts ¶ added in v3.0.19
func (*Node) GetEdges ¶
func (node *Node) GetEdges(dir EdgeDir) EdgeIterator
Returns an edge iterator for incoming or outgoing edges
func (*Node) GetEdgesWithAnyLabel ¶
func (node *Node) GetEdgesWithAnyLabel(dir EdgeDir, labels *StringSet) EdgeIterator
Returns an edge iterator for incoming or outgoingn edges that has the given labels
func (*Node) GetEdgesWithLabel ¶
func (node *Node) GetEdgesWithLabel(dir EdgeDir, label string) EdgeIterator
Returns an edge iterator for incoming or outgoing edges with the given label
func (*Node) GetID ¶
GetID returns the unique node ID. The ID is meaningless if the node is removed from the graph
func (*Node) GetNLabels ¶ added in v3.0.2
func (*Node) GetProperty ¶
GetProperty returns the property value in the string table
func (*Node) HasAllContext ¶ added in v3.0.3
func (*Node) HasAllContextsSet ¶ added in v3.0.12
func (*Node) HasAllLabels ¶ added in v3.0.3
func (*Node) HasAnyContext ¶ added in v3.0.3
func (*Node) HasAnyContextsSet ¶ added in v3.0.12
func (*Node) HasAnyLabel ¶ added in v3.0.3
func (*Node) IncomingEdgeCount ¶ added in v3.0.17
func (*Node) OutgoingEdgeCount ¶ added in v3.0.17
func (*Node) RemoveProperty ¶
RemoveProperty removes a node property
func (*Node) SetContexts ¶ added in v3.0.3
func (*Node) SetProperty ¶
SetProperty sets a node property
type NodeIterator ¶
NodeIterator iterates nodes of an underlying list
func SinksItr ¶
func SinksItr(graph *Graph) NodeIterator
Sinks finds all the sink nodes in the graph
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 NewNodeMap ¶
func NewNodeMap() *NodeMap
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 NewNodeSet ¶
func NewNodeSet() *NodeSet
func (*NodeSet) Iterator ¶
func (set *NodeSet) Iterator() NodeIterator
type Path ¶
type Path struct {
// contains filtered or unexported fields
}
A Path can be a node, or node-edge-node...-edge-node sequence.
func NewPathFromElements ¶
func NewPathFromElements(elements ...PathElement) *Path
func PathFromNode ¶
PathFromNode creates a path containing a single node
func (*Path) Append ¶
func (p *Path) Append(path ...PathElement) *Path
Append an edge to the end of the path. The edge must be outgoing from the last node of the path
func (*Path) AppendPath ¶
AppendPath can append a single node or a path to the callers path. If the caller does not contain a path, the passed path is copied into the receiver
func (*Path) HasPrefix ¶
func (p *Path) HasPrefix(p1 []PathElement) bool
HasPrefix return if all edges of p1 exist in path
func (*Path) HasPrefixPath ¶
HasPrefixPaths returns if all paths elements of p1 exist in path
func (*Path) RemoveFirst ¶
RemoveFirst removes the first edge from the graph. If the path has only a node, path becomes empty
func (*Path) RemoveLast ¶
RemoveLast removes the last edge from the path. If the path has one edge, the path becomes a single node containing the source. If the path has only a node, path becomes empty
func (*Path) SetOnlyNode ¶
SetOnlyNode sets the path to a single node
type PathElement ¶
func NewPathElementsFromEdges ¶
func NewPathElementsFromEdges(edges []*Edge) []PathElement
func (PathElement) GetSourceNode ¶
func (p PathElement) GetSourceNode() *Node
func (PathElement) GetTargetNode ¶
func (p PathElement) GetTargetNode() *Node
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 *Path)
func (*PatternSymbol) EdgeSlice ¶
func (p *PatternSymbol) EdgeSlice() *Path
func (*PatternSymbol) NodeSlice ¶
func (p *PatternSymbol) NodeSlice() []*Node
type StringSet ¶
type StringSet struct {
M *fastMap
}
func FastNewStringSet ¶ added in v3.0.16
uses a pre existing stringset or creates a new one if empty
func NewStringSet ¶
func (*StringSet) Iterator ¶ added in v3.0.16
// func (f *StringSet) Iterator() Iterator { // next, stop := iter.Pull[string](f.Range()) // return &sIterator{next: next, stop: stop, set: f} // }
func (*StringSet) SortedSlice ¶
type WithNativeValue ¶
type WithNativeValue interface {
GetNativeValue() interface{}
}
WithNativeValue is used to return a native value for property values. If the property value implements this interface, the underlying native value for indexing and comparison is obtained from this interface.