PatternGraph

Trait PatternGraph 

Source
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§

Source

fn add_node<C>(&mut self, condition: C) -> Self::NodeRef
where C: Fn(&NodeWeight) -> bool + 'static,

Adds a new node to the pattern.

A matched node appears in the result graph.

§Input:

condition, a Matcher that holds a function to test if a node in a base graph matches what we want in the pattern graph.

§Output:

A node reference.

Source

fn add_hidden_node<C>(&mut self, condition: C) -> Self::NodeRef
where C: Fn(&NodeWeight) -> bool + 'static,

Adds a new hidden node to the pattern. A node that matches does not appear in the result graph, but is required to exist in the searched graph.

§Input:

condition, a Matcher that holds a function to test if a node in a base graph matches. what we want in the pattern graph.

§Output:

A node reference.

Source

fn add_edge<C>( &mut self, from: Self::NodeRef, to: Self::NodeRef, condition: C, ) -> Self::EdgeRef
where C: Fn(&EdgeWeight) -> bool + 'static,

Adds a new edge to the pattern. This edge will appear in the result graphs.

§Input:
  1. from, the source node of the new edge.
  2. to, the destination node.
  3. 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.

Source

fn add_hidden_edge<C>( &mut self, from: Self::NodeRef, to: Self::NodeRef, condition: C, ) -> Self::EdgeRef
where C: Fn(&EdgeWeight) -> bool + 'static,

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:
  1. from, the source node of the new edge.
  2. to, the destination node.
  3. 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.

Source§

fn add_hidden_node<C>(&mut self, condition: C) -> Self::NodeRef
where C: Fn(&NodeWeight) -> bool + 'static,

Adds a hidden node to match, and returns the reference.

Source§

fn add_node<C>(&mut self, condition: C) -> Self::NodeRef
where C: Fn(&NodeWeight) -> bool + 'static,

Adds a visible node to match, and returns the reference.

Source§

fn add_hidden_edge<C>( &mut self, from: Self::NodeRef, to: Self::NodeRef, condition: C, ) -> Self::EdgeRef
where C: Fn(&EdgeWeight) -> bool + 'static,

Adds a hidden/ignored edge to match, and returns the reference.

Source§

fn add_edge<C>( &mut self, from: Self::NodeRef, to: Self::NodeRef, condition: C, ) -> Self::EdgeRef
where C: Fn(&EdgeWeight) -> bool + 'static,

Adds an edge to match, and returns the reference.

Implementors§