Trait Graph

Source
pub trait Graph: Default + Clone {
    type Node: Ord + Copy;
    type Edge: Ord + Copy;
    type PortLabel: Ord + Clone;

    // Required methods
    fn nodes_iter(&self) -> impl Iterator<Item = Self::Node> + '_;
    fn edges_iter(&self) -> impl Iterator<Item = Self::Edge> + '_;
    fn get_port_site(
        &self,
        bound_port: BoundPort<Self::Edge>,
    ) -> Site<Self::Node, Self::PortLabel>;
    fn get_bound_ports(
        &self,
        site: Site<Self::Node, Self::PortLabel>,
    ) -> impl Iterator<Item = BoundPort<Self::Edge>> + '_;
    fn get_sites(
        &self,
        node: Self::Node,
    ) -> impl Iterator<Item = Site<Self::Node, Self::PortLabel>> + '_;
    fn link_sites(
        &mut self,
        left: Site<Self::Node, Self::PortLabel>,
        right: Site<Self::Node, Self::PortLabel>,
    );
    fn add_subgraph(
        &mut self,
        graph: &Self,
        nodes: &BTreeSet<Self::Node>,
    ) -> BTreeMap<Self::Node, Self::Node>;

    // Provided method
    fn incident_node(&self, edge: Self::Edge, end: EdgeEnd) -> Self::Node { ... }
}
Expand description

A graph for port diffing.

It must be possible to iterate through all nodes and edges of the graph. Furthermore, each edge must distinguish a left end and a right end. This does not have to match the directedness of the edge, but it must be fixed.

Incident edges can furthermore be distinguished using a port label type, attached to the edge ends.

Required Associated Types§

Required Methods§

Source

fn nodes_iter(&self) -> impl Iterator<Item = Self::Node> + '_

Iterate over all nodes in the graph.

Source

fn edges_iter(&self) -> impl Iterator<Item = Self::Edge> + '_

Iterate over all edges in the graph.

Source

fn get_port_site( &self, bound_port: BoundPort<Self::Edge>, ) -> Site<Self::Node, Self::PortLabel>

Find the site of a bound port.

There is a unique site for every bound port. The reverse is not true: site may not have an incident edge, or may have multiple.

Source

fn get_bound_ports( &self, site: Site<Self::Node, Self::PortLabel>, ) -> impl Iterator<Item = BoundPort<Self::Edge>> + '_

Source

fn get_sites( &self, node: Self::Node, ) -> impl Iterator<Item = Site<Self::Node, Self::PortLabel>> + '_

Source

fn add_subgraph( &mut self, graph: &Self, nodes: &BTreeSet<Self::Node>, ) -> BTreeMap<Self::Node, Self::Node>

Add a subgraph of graph to self.

Add the subgraph of graph that is induced by nodes.

Return a map from nodes in graph to the new nodes in self.

Provided Methods§

Source

fn incident_node(&self, edge: Self::Edge, end: EdgeEnd) -> Self::Node

The node incident to a given edge and port side.

This can be obtained from the bound -> unbound port map.

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.

Implementors§