pub trait PatternGraph<NodeWeight, EdgeWeight>: Graph<PatternElement<NodeWeight>, PatternElement<EdgeWeight>> {
// Required methods
fn add_node<C>(&mut self, condition: C) -> Self::NodeRef
where C: Fn(&NodeWeight) -> bool + 'static;
fn add_hidden_node<C>(&mut self, condition: C) -> Self::NodeRef
where C: Fn(&NodeWeight) -> bool + 'static;
fn add_edge<C>(
&mut self,
from: Self::NodeRef,
to: Self::NodeRef,
condition: C,
) -> Self::EdgeRef
where C: Fn(&EdgeWeight) -> bool + 'static;
fn add_hidden_edge<C>(
&mut self,
from: Self::NodeRef,
to: Self::NodeRef,
condition: C,
) -> Self::EdgeRef
where C: Fn(&EdgeWeight) -> bool + 'static;
}Expand description
Defines a pattern graph, i.e. a specification for subgraphs that we want to find. This trait extends the Graph trait, to allow for navigation & getting subgraph info.
A pattern graph uses matcher functions as weights. With matcher functions, we can test if an element semantically fits to a subgraph to be found, for example, if it matches a given Rust pattern.
PatternGraph is generic with regards to node and edge weights of the graphs it should match on.
Required Methods§
Sourcefn add_edge<C>(
&mut self,
from: Self::NodeRef,
to: Self::NodeRef,
condition: C,
) -> Self::EdgeRef
fn add_edge<C>( &mut self, from: Self::NodeRef, to: Self::NodeRef, condition: C, ) -> Self::EdgeRef
Adds a new edge to the pattern. This edge will appear in the result graphs.
§Input:
from, the source node of the new edge.to, the destination node.condition, a function to test if an edge in a base graph matches what we want in the pattern graph.
§Output:
An edge reference.
§Panics:
Panics if one of the adjacent nodes is a hidden node.
Adds a new, directed, hidden edge to the pattern.
An edge that matches does not appear in the result graph, but is required to exist in the searched graph.
§Input:
from, the source node of the new edge.to, the destination node.condition, a function to test if an edge in a base graph matches what we want in the pattern graph.
§Output:
An edge reference.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl<NodeWeight, EdgeWeight> PatternGraph<NodeWeight, EdgeWeight> for Graph<PatternElement<NodeWeight>, PatternElement<EdgeWeight>>
Defines an PatternGraph over an directed petgraph. Guarantees that
our graph should always be directed.
impl<NodeWeight, EdgeWeight> PatternGraph<NodeWeight, EdgeWeight> for Graph<PatternElement<NodeWeight>, PatternElement<EdgeWeight>>
Defines an PatternGraph over an directed petgraph. Guarantees that our graph should always be directed.