pub struct PathPattern { /* private fields */ }Expand description
Path pattern matcher.
Matches paths against a sequence of steps, supporting variable-length patterns and filters.
§Example
ⓘ
// Pattern: (a)-[:KNOWS]->(b)-[:WORKS_AT]->(c)
let pattern = PathPattern::new()
.add_step(PathStep::outgoing("KNOWS"))
.add_step(PathStep::outgoing("WORKS_AT"));
let matches = pattern.find_from(&tx, start_node)?;
// Variable-length: (a)-[:FRIEND*1..3]->(b)
let pattern = PathPattern::new()
.add_step(PathStep::outgoing("FRIEND").variable_length(1, 3));Implementations§
Source§impl PathPattern
impl PathPattern
Sourcepub fn outgoing(self, edge_type: impl Into<EdgeType>) -> Self
pub fn outgoing(self, edge_type: impl Into<EdgeType>) -> Self
Add an outgoing step with the given edge type.
Sourcepub fn incoming(self, edge_type: impl Into<EdgeType>) -> Self
pub fn incoming(self, edge_type: impl Into<EdgeType>) -> Self
Add an incoming step with the given edge type.
Sourcepub fn both(self, edge_type: impl Into<EdgeType>) -> Self
pub fn both(self, edge_type: impl Into<EdgeType>) -> Self
Add a bidirectional step with the given edge type.
Sourcepub const fn with_limit(self, limit: usize) -> Self
pub const fn with_limit(self, limit: usize) -> Self
Set the maximum number of matches to return.
Sourcepub const fn allow_cycles(self) -> Self
pub const fn allow_cycles(self) -> Self
Allow cycles in matched paths.
By default, nodes cannot be visited more than once in a path.
Sourcepub fn find_from<T: Transaction>(
&self,
tx: &T,
start: EntityId,
) -> GraphResult<Vec<PatternMatch>>
pub fn find_from<T: Transaction>( &self, tx: &T, start: EntityId, ) -> GraphResult<Vec<PatternMatch>>
Find all paths matching this pattern from a starting node.
Sourcepub fn find_between<T: Transaction>(
&self,
tx: &T,
start: EntityId,
end: EntityId,
) -> GraphResult<Vec<PatternMatch>>
pub fn find_between<T: Transaction>( &self, tx: &T, start: EntityId, end: EntityId, ) -> GraphResult<Vec<PatternMatch>>
Find paths matching this pattern that end at a specific node.
Sourcepub fn matches<T: Transaction>(
&self,
tx: &T,
start: EntityId,
) -> GraphResult<bool>
pub fn matches<T: Transaction>( &self, tx: &T, start: EntityId, ) -> GraphResult<bool>
Check if any path matches this pattern from the given start.
Trait Implementations§
Source§impl Clone for PathPattern
impl Clone for PathPattern
Source§fn clone(&self) -> PathPattern
fn clone(&self) -> PathPattern
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PathPattern
impl Debug for PathPattern
Source§impl Default for PathPattern
impl Default for PathPattern
Source§fn default() -> PathPattern
fn default() -> PathPattern
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for PathPattern
impl RefUnwindSafe for PathPattern
impl Send for PathPattern
impl Sync for PathPattern
impl Unpin for PathPattern
impl UnsafeUnpin for PathPattern
impl UnwindSafe for PathPattern
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more