pub trait LinkView: PortView {
type LinkEndpoint: Into<PortIndex> + Copy;
Show 14 methods
// Required methods
fn get_connections(
&self,
from: NodeIndex,
to: NodeIndex,
) -> impl Iterator<Item = (Self::LinkEndpoint, Self::LinkEndpoint)> + Clone;
fn port_links(
&self,
port: PortIndex,
) -> impl Iterator<Item = (Self::LinkEndpoint, Self::LinkEndpoint)> + Clone;
fn links(
&self,
node: NodeIndex,
direction: Direction,
) -> impl Iterator<Item = (Self::LinkEndpoint, Self::LinkEndpoint)> + Clone;
fn all_links(
&self,
node: NodeIndex,
) -> impl Iterator<Item = (Self::LinkEndpoint, Self::LinkEndpoint)> + Clone;
fn neighbours(
&self,
node: NodeIndex,
direction: Direction,
) -> impl Iterator<Item = NodeIndex> + Clone;
fn all_neighbours(
&self,
node: NodeIndex,
) -> impl Iterator<Item = NodeIndex> + Clone;
fn link_count(&self) -> usize;
// Provided methods
fn get_connection(
&self,
from: NodeIndex,
to: NodeIndex,
) -> Option<(Self::LinkEndpoint, Self::LinkEndpoint)> { ... }
fn connected(&self, from: NodeIndex, to: NodeIndex) -> bool { ... }
fn port_link(&self, port: PortIndex) -> Option<Self::LinkEndpoint> { ... }
fn input_links(
&self,
node: NodeIndex,
) -> impl Iterator<Item = (Self::LinkEndpoint, Self::LinkEndpoint)> + Clone { ... }
fn output_links(
&self,
node: NodeIndex,
) -> impl Iterator<Item = (Self::LinkEndpoint, Self::LinkEndpoint)> + Clone { ... }
fn input_neighbours(
&self,
node: NodeIndex,
) -> impl Iterator<Item = NodeIndex> + Clone { ... }
fn output_neighbours(
&self,
node: NodeIndex,
) -> impl Iterator<Item = NodeIndex> + Clone { ... }
}Expand description
Operations pertaining the adjacency of nodes in a port graph.
Required Associated Types§
Sourcetype LinkEndpoint: Into<PortIndex> + Copy
type LinkEndpoint: Into<PortIndex> + Copy
The identifier for the endpoints of a link.
Required Methods§
Sourcefn get_connections(
&self,
from: NodeIndex,
to: NodeIndex,
) -> impl Iterator<Item = (Self::LinkEndpoint, Self::LinkEndpoint)> + Clone
fn get_connections( &self, from: NodeIndex, to: NodeIndex, ) -> impl Iterator<Item = (Self::LinkEndpoint, Self::LinkEndpoint)> + Clone
Returns an iterator over every pair of matching ports connecting from
to to, i.e. in that direction.
§Example
let mut g: PortGraph = PortGraph::new();
let a = g.add_node(0, 2);
let b = g.add_node(2, 0);
g.link_nodes(a, 0, b, 0).unwrap();
g.link_nodes(a, 1, b, 1).unwrap();
let mut connections = g.get_connections(a, b);
assert_eq!(connections.next(), Some((g.output(a,0).unwrap(), g.input(b,0).unwrap())));
assert_eq!(connections.next(), Some((g.output(a,1).unwrap(), g.input(b,1).unwrap())));
assert_eq!(connections.next(), None);Sourcefn port_links(
&self,
port: PortIndex,
) -> impl Iterator<Item = (Self::LinkEndpoint, Self::LinkEndpoint)> + Clone
fn port_links( &self, port: PortIndex, ) -> impl Iterator<Item = (Self::LinkEndpoint, Self::LinkEndpoint)> + Clone
Returns the port (or ports if this is a MultiView) that the given port is linked to.
Sourcefn links(
&self,
node: NodeIndex,
direction: Direction,
) -> impl Iterator<Item = (Self::LinkEndpoint, Self::LinkEndpoint)> + Clone
fn links( &self, node: NodeIndex, direction: Direction, ) -> impl Iterator<Item = (Self::LinkEndpoint, Self::LinkEndpoint)> + Clone
Iterates over the connected links of the node in the given
direction.
§Examples
let mut graph: PortGraph = PortGraph::new();
let node_a = graph.add_node(0, 2);
let node_b = graph.add_node(1, 0);
let port_a = graph.outputs(node_a).next().unwrap();
let port_b = graph.inputs(node_b).next().unwrap();
graph.link_ports(port_a, port_b).unwrap();
assert!(graph.links(node_a, Direction::Outgoing).eq([(port_a, port_b)]));
assert!(graph.links(node_b, Direction::Incoming).eq([(port_b, port_a)]));Sourcefn all_links(
&self,
node: NodeIndex,
) -> impl Iterator<Item = (Self::LinkEndpoint, Self::LinkEndpoint)> + Clone
fn all_links( &self, node: NodeIndex, ) -> impl Iterator<Item = (Self::LinkEndpoint, Self::LinkEndpoint)> + Clone
Iterates over the connected input and output links of the node in sequence.
Sourcefn neighbours(
&self,
node: NodeIndex,
direction: Direction,
) -> impl Iterator<Item = NodeIndex> + Clone
fn neighbours( &self, node: NodeIndex, direction: Direction, ) -> impl Iterator<Item = NodeIndex> + Clone
Iterates over neighbour nodes in the given direction.
May contain duplicates if the graph has multiple links between nodes.
§Examples
let mut graph: PortGraph = PortGraph::new();
let a = graph.add_node(0, 1);
let b = graph.add_node(2, 1);
graph.link_nodes(a, 0, b, 0).unwrap();
graph.link_nodes(b, 0, b, 1).unwrap();
assert!(graph.neighbours(a, Direction::Outgoing).eq([b]));
assert!(graph.neighbours(b, Direction::Incoming).eq([a,b]));Sourcefn all_neighbours(
&self,
node: NodeIndex,
) -> impl Iterator<Item = NodeIndex> + Clone
fn all_neighbours( &self, node: NodeIndex, ) -> impl Iterator<Item = NodeIndex> + Clone
Iterates over the input and output neighbours of the node in sequence.
Sourcefn link_count(&self) -> usize
fn link_count(&self) -> usize
Returns the number of links between ports.
Provided Methods§
Sourcefn get_connection(
&self,
from: NodeIndex,
to: NodeIndex,
) -> Option<(Self::LinkEndpoint, Self::LinkEndpoint)>
fn get_connection( &self, from: NodeIndex, to: NodeIndex, ) -> Option<(Self::LinkEndpoint, Self::LinkEndpoint)>
Checks whether there is a directed link between the two nodes and returns the first matching pair of ports.
§Example
let mut g: PortGraph = PortGraph::new();
let a = g.add_node(0, 2);
let b = g.add_node(2, 0);
g.link_nodes(a, 0, b, 0).unwrap();
g.link_nodes(a, 1, b, 1).unwrap();
assert_eq!(g.get_connection(a, b), Some((g.output(a,0).unwrap(), g.input(b,0).unwrap())));Sourcefn connected(&self, from: NodeIndex, to: NodeIndex) -> bool
fn connected(&self, from: NodeIndex, to: NodeIndex) -> bool
Checks whether there is a directed link between the two nodes.
§Example
let mut g: PortGraph = PortGraph::new();
let a = g.add_node(0, 2);
let b = g.add_node(2, 0);
g.link_nodes(a, 0, b, 0).unwrap();
assert!(g.connected(a, b));Sourcefn port_link(&self, port: PortIndex) -> Option<Self::LinkEndpoint>
fn port_link(&self, port: PortIndex) -> Option<Self::LinkEndpoint>
Return the link to the provided port, if not connected return None. If this port has multiple connected subports, an arbitrary one is returned.
Sourcefn input_links(
&self,
node: NodeIndex,
) -> impl Iterator<Item = (Self::LinkEndpoint, Self::LinkEndpoint)> + Clone
fn input_links( &self, node: NodeIndex, ) -> impl Iterator<Item = (Self::LinkEndpoint, Self::LinkEndpoint)> + Clone
Iterates over the connected input links of the node. Shorthand for
LinkView::links(Direction::Incoming).
Sourcefn output_links(
&self,
node: NodeIndex,
) -> impl Iterator<Item = (Self::LinkEndpoint, Self::LinkEndpoint)> + Clone
fn output_links( &self, node: NodeIndex, ) -> impl Iterator<Item = (Self::LinkEndpoint, Self::LinkEndpoint)> + Clone
Iterates over the connected output links of the node. Shorthand for
LinkView::links(Direction::Outgoing)..
Sourcefn input_neighbours(
&self,
node: NodeIndex,
) -> impl Iterator<Item = NodeIndex> + Clone
fn input_neighbours( &self, node: NodeIndex, ) -> impl Iterator<Item = NodeIndex> + Clone
Iterates over the input neighbours of the node.
Shorthand for LinkView::neighbours(Direction::Incoming).
Sourcefn output_neighbours(
&self,
node: NodeIndex,
) -> impl Iterator<Item = NodeIndex> + Clone
fn output_neighbours( &self, node: NodeIndex, ) -> impl Iterator<Item = NodeIndex> + Clone
Iterates over the output neighbours of the node.
Shorthand for LinkView::neighbours(Direction::Outgoing).
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<G: LinkView> LinkView for &G
impl<G: LinkView> LinkView for &G
type LinkEndpoint = <G as LinkView>::LinkEndpoint
fn get_connections( &self, from: NodeIndex, to: NodeIndex, ) -> impl Iterator<Item = (Self::LinkEndpoint, Self::LinkEndpoint)> + Clone
fn port_links( &self, port: PortIndex, ) -> impl Iterator<Item = (Self::LinkEndpoint, Self::LinkEndpoint)> + Clone
fn links( &self, node: NodeIndex, direction: Direction, ) -> impl Iterator<Item = (Self::LinkEndpoint, Self::LinkEndpoint)> + Clone
fn all_links( &self, node: NodeIndex, ) -> impl Iterator<Item = (Self::LinkEndpoint, Self::LinkEndpoint)> + Clone
fn neighbours( &self, node: NodeIndex, direction: Direction, ) -> impl Iterator<Item = NodeIndex> + Clone
fn all_neighbours( &self, node: NodeIndex, ) -> impl Iterator<Item = NodeIndex> + Clone
fn link_count(&self) -> usize
Source§impl<G: LinkView> LinkView for &mut G
impl<G: LinkView> LinkView for &mut G
type LinkEndpoint = <G as LinkView>::LinkEndpoint
fn get_connections( &self, from: NodeIndex, to: NodeIndex, ) -> impl Iterator<Item = (Self::LinkEndpoint, Self::LinkEndpoint)> + Clone
fn port_links( &self, port: PortIndex, ) -> impl Iterator<Item = (Self::LinkEndpoint, Self::LinkEndpoint)> + Clone
fn links( &self, node: NodeIndex, direction: Direction, ) -> impl Iterator<Item = (Self::LinkEndpoint, Self::LinkEndpoint)> + Clone
fn all_links( &self, node: NodeIndex, ) -> impl Iterator<Item = (Self::LinkEndpoint, Self::LinkEndpoint)> + Clone
fn neighbours( &self, node: NodeIndex, direction: Direction, ) -> impl Iterator<Item = NodeIndex> + Clone
fn all_neighbours( &self, node: NodeIndex, ) -> impl Iterator<Item = NodeIndex> + Clone
fn link_count(&self) -> usize
Implementors§
Source§impl<G> LinkView for FlatRegion<'_, G>
impl<G> LinkView for FlatRegion<'_, G>
type LinkEndpoint = <G as LinkView>::LinkEndpoint
Source§impl<G> LinkView for Region<'_, G>
impl<G> LinkView for Region<'_, G>
type LinkEndpoint = <G as LinkView>::LinkEndpoint
Source§impl<G, Ctx> LinkView for FilteredGraph<G, NodeFilter<Ctx>, LinkFilter<Ctx>, Ctx>
impl<G, Ctx> LinkView for FilteredGraph<G, NodeFilter<Ctx>, LinkFilter<Ctx>, Ctx>
type LinkEndpoint = <G as LinkView>::LinkEndpoint
Source§impl<G: LinkView> LinkView for DynamicTopoConvexChecker<G>
Implement LinkView for DynamicTopoConvexChecker
impl<G: LinkView> LinkView for DynamicTopoConvexChecker<G>
Implement LinkView for DynamicTopoConvexChecker