Struct portgraph::multiportgraph::MultiPortGraph
source · pub struct MultiPortGraph { /* private fields */ }Expand description
An unlabelled port graph that allows multiple links to the same ports.
A port graph consists of a collection of nodes identified by a NodeIndex.
Each node has an ordered sequence of input and output ports, identified by a PortIndex that is unique within the graph.
To optimize for the most common use case, the number of input and output ports of a node must be specified when the node is created.
Multiple connections to the same PortIndex can be distinguished by their SubportIndex.
When a node and its associated ports are removed their indices will be reused on a best effort basis when a new node is added. The indices of unaffected nodes and ports remain stable.
Implementations§
source§impl MultiPortGraph
impl MultiPortGraph
sourcepub fn new() -> Self
pub fn new() -> Self
Create a new empty MultiPortGraph.
sourcepub fn with_capacity(nodes: usize, ports: usize) -> Self
pub fn with_capacity(nodes: usize, ports: usize) -> Self
Create a new empty MultiPortGraph with preallocated capacity.
sourcepub fn as_portgraph(&self) -> &PortGraph
pub fn as_portgraph(&self) -> &PortGraph
Returns a reference to the internal plain portgraph.
This graph exposes the copy nodes as well as the main nodes.
sourcepub fn pg_main_node(&self, node: NodeIndex) -> NodeIndex
pub fn pg_main_node(&self, node: NodeIndex) -> NodeIndex
Given a node in the underlying flat portgraph, returns the main node for it.
If the node is not a copy node, returns the node itself.
Trait Implementations§
source§impl Clone for MultiPortGraph
impl Clone for MultiPortGraph
source§fn clone(&self) -> MultiPortGraph
fn clone(&self) -> MultiPortGraph
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for MultiPortGraph
impl Debug for MultiPortGraph
source§impl Default for MultiPortGraph
impl Default for MultiPortGraph
source§fn default() -> MultiPortGraph
fn default() -> MultiPortGraph
source§impl From<MultiPortGraph> for PortGraph
impl From<MultiPortGraph> for PortGraph
source§fn from(multi: MultiPortGraph) -> Self
fn from(multi: MultiPortGraph) -> Self
source§impl From<PortGraph> for MultiPortGraph
impl From<PortGraph> for MultiPortGraph
source§impl LinkMut for MultiPortGraph
impl LinkMut for MultiPortGraph
source§fn link_ports(
&mut self,
port_a: PortIndex,
port_b: PortIndex
) -> Result<(SubportIndex, SubportIndex), LinkError>
fn link_ports( &mut self, port_a: PortIndex, port_b: PortIndex ) -> Result<(SubportIndex, SubportIndex), LinkError>
source§fn unlink_port(&mut self, port: PortIndex) -> Option<SubportIndex>
fn unlink_port(&mut self, port: PortIndex) -> Option<SubportIndex>
port. If the port was connected,
returns one of the ports it was connected to.source§fn link_nodes(
&mut self,
from: NodeIndex,
from_output: usize,
to: NodeIndex,
to_input: usize
) -> Result<(Self::LinkEndpoint, Self::LinkEndpoint), LinkError>
fn link_nodes( &mut self, from: NodeIndex, from_output: usize, to: NodeIndex, to_input: usize ) -> Result<(Self::LinkEndpoint, Self::LinkEndpoint), LinkError>
source§fn link_offsets(
&mut self,
node_a: NodeIndex,
offset_a: PortOffset,
node_b: NodeIndex,
offset_b: PortOffset
) -> Result<(Self::LinkEndpoint, Self::LinkEndpoint), LinkError>
fn link_offsets( &mut self, node_a: NodeIndex, offset_a: PortOffset, node_b: NodeIndex, offset_b: PortOffset ) -> Result<(Self::LinkEndpoint, Self::LinkEndpoint), LinkError>
source§impl LinkView for MultiPortGraph
impl LinkView for MultiPortGraph
§type LinkEndpoint = SubportIndex
type LinkEndpoint = SubportIndex
§type Neighbours<'a> = Neighbours<'a>
where
Self: 'a
type Neighbours<'a> = Neighbours<'a> where Self: 'a
§type NodeConnections<'a> = NodeConnections<'a>
where
Self: 'a
type NodeConnections<'a> = NodeConnections<'a> where Self: 'a
§type NodeLinks<'a> = NodeLinks<'a>
where
Self: 'a
type NodeLinks<'a> = NodeLinks<'a> where Self: 'a
§type PortLinks<'a> = PortLinks<'a>
where
Self: 'a
type PortLinks<'a> = PortLinks<'a> where Self: 'a
source§fn get_connections(
&self,
from: NodeIndex,
to: NodeIndex
) -> Self::NodeConnections<'_>
fn get_connections( &self, from: NodeIndex, to: NodeIndex ) -> Self::NodeConnections<'_>
source§fn port_links(&self, port: PortIndex) -> Self::PortLinks<'_>
fn port_links(&self, port: PortIndex) -> Self::PortLinks<'_>
port is linked to.source§fn all_links(&self, node: NodeIndex) -> Self::NodeLinks<'_>
fn all_links(&self, node: NodeIndex) -> Self::NodeLinks<'_>
node in sequence.source§fn neighbours(
&self,
node: NodeIndex,
direction: Direction
) -> Self::Neighbours<'_>
fn neighbours( &self, node: NodeIndex, direction: Direction ) -> Self::Neighbours<'_>
direction.
May contain duplicates if the graph has multiple links between nodes. Read moresource§fn all_neighbours(&self, node: NodeIndex) -> Self::Neighbours<'_>
fn all_neighbours(&self, node: NodeIndex) -> Self::Neighbours<'_>
node in sequence.source§fn link_count(&self) -> usize
fn link_count(&self) -> usize
source§fn 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)>
source§fn connected(&self, from: NodeIndex, to: NodeIndex) -> bool
fn connected(&self, from: NodeIndex, to: NodeIndex) -> bool
source§fn port_link(&self, port: PortIndex) -> Option<Self::LinkEndpoint>
fn port_link(&self, port: PortIndex) -> Option<Self::LinkEndpoint>
source§fn input_links(&self, node: NodeIndex) -> Self::NodeLinks<'_>
fn input_links(&self, node: NodeIndex) -> Self::NodeLinks<'_>
node. Shorthand for
LinkView::links.source§fn output_links(&self, node: NodeIndex) -> Self::NodeLinks<'_>
fn output_links(&self, node: NodeIndex) -> Self::NodeLinks<'_>
node. Shorthand for
LinkView::links.source§fn input_neighbours(&self, node: NodeIndex) -> Self::Neighbours<'_>
fn input_neighbours(&self, node: NodeIndex) -> Self::Neighbours<'_>
node. Shorthand for LinkView::neighbours.source§fn output_neighbours(&self, node: NodeIndex) -> Self::Neighbours<'_>
fn output_neighbours(&self, node: NodeIndex) -> Self::Neighbours<'_>
node. Shorthand for LinkView::neighbours.source§impl MultiMut for MultiPortGraph
impl MultiMut for MultiPortGraph
source§fn link_subports(
&mut self,
subport_from: SubportIndex,
subport_to: SubportIndex
) -> Result<(), LinkError>
fn link_subports( &mut self, subport_from: SubportIndex, subport_to: SubportIndex ) -> Result<(), LinkError>
source§fn unlink_subport(&mut self, subport: SubportIndex) -> Option<SubportIndex>
fn unlink_subport(&mut self, subport: SubportIndex) -> Option<SubportIndex>
port and returns the subport it was linked to. Returns None
when the port was not linked.source§impl MultiView for MultiPortGraph
impl MultiView for MultiPortGraph
§type NodeSubports<'a> = NodeSubports<'a>
where
Self: 'a
type NodeSubports<'a> = NodeSubports<'a> where Self: 'a
source§fn subport_link(&self, subport: SubportIndex) -> Option<SubportIndex>
fn subport_link(&self, subport: SubportIndex) -> Option<SubportIndex>
port. If the port is not
connected, return None.source§fn subports(
&self,
node: NodeIndex,
direction: Direction
) -> Self::NodeSubports<'_>
fn subports( &self, node: NodeIndex, direction: Direction ) -> Self::NodeSubports<'_>
node in the given direction.source§fn all_subports(&self, node: NodeIndex) -> Self::NodeSubports<'_>
fn all_subports(&self, node: NodeIndex) -> Self::NodeSubports<'_>
node in sequence.source§fn subport_inputs(&self, node: NodeIndex) -> Self::NodeSubports<'_>
fn subport_inputs(&self, node: NodeIndex) -> Self::NodeSubports<'_>
node. Read moresource§fn subport_outputs(&self, node: NodeIndex) -> Self::NodeSubports<'_>
fn subport_outputs(&self, node: NodeIndex) -> Self::NodeSubports<'_>
node. Read moresource§impl PartialEq for MultiPortGraph
impl PartialEq for MultiPortGraph
source§fn eq(&self, other: &MultiPortGraph) -> bool
fn eq(&self, other: &MultiPortGraph) -> bool
self and other values to be equal, and is used
by ==.source§impl PortMut for MultiPortGraph
impl PortMut for MultiPortGraph
source§fn add_node(&mut self, incoming: usize, outgoing: usize) -> NodeIndex
fn add_node(&mut self, incoming: usize, outgoing: usize) -> NodeIndex
source§fn remove_node(&mut self, node: NodeIndex)
fn remove_node(&mut self, node: NodeIndex)
source§fn reserve(&mut self, nodes: usize, ports: usize)
fn reserve(&mut self, nodes: usize, ports: usize)
source§fn set_num_ports<F>(
&mut self,
node: NodeIndex,
incoming: usize,
outgoing: usize,
rekey: F
)
fn set_num_ports<F>( &mut self, node: NodeIndex, incoming: usize, outgoing: usize, rekey: F )
source§fn compact_nodes<F>(&mut self, rekey: F)
fn compact_nodes<F>(&mut self, rekey: F)
source§fn swap_nodes(&mut self, a: NodeIndex, b: NodeIndex)
fn swap_nodes(&mut self, a: NodeIndex, b: NodeIndex)
source§fn compact_ports<F>(&mut self, rekey: F)
fn compact_ports<F>(&mut self, rekey: F)
source§fn shrink_to_fit(&mut self)
fn shrink_to_fit(&mut self)
source§impl PortView for MultiPortGraph
impl PortView for MultiPortGraph
§type NodePortOffsets<'a> = NodePortOffsets
where
Self: 'a
type NodePortOffsets<'a> = NodePortOffsets where Self: 'a
source§fn port_direction(&self, port: impl Into<PortIndex>) -> Option<Direction>
fn port_direction(&self, port: impl Into<PortIndex>) -> Option<Direction>
port.source§fn port_node(&self, port: impl Into<PortIndex>) -> Option<NodeIndex>
fn port_node(&self, port: impl Into<PortIndex>) -> Option<NodeIndex>
port belongs to.source§fn port_offset(&self, port: impl Into<PortIndex>) -> Option<PortOffset>
fn port_offset(&self, port: impl Into<PortIndex>) -> Option<PortOffset>
port within its node’s port list.source§fn port_index(&self, node: NodeIndex, offset: PortOffset) -> Option<PortIndex>
fn port_index(&self, node: NodeIndex, offset: PortOffset) -> Option<PortIndex>
source§fn ports(&self, node: NodeIndex, direction: Direction) -> Self::NodePorts<'_>
fn ports(&self, node: NodeIndex, direction: Direction) -> Self::NodePorts<'_>
node in the given direction.source§fn all_ports(&self, node: NodeIndex) -> Self::NodePorts<'_>
fn all_ports(&self, node: NodeIndex) -> Self::NodePorts<'_>
node in sequence.source§fn input(&self, node: NodeIndex, offset: usize) -> Option<PortIndex>
fn input(&self, node: NodeIndex, offset: usize) -> Option<PortIndex>
node. Read moresource§fn output(&self, node: NodeIndex, offset: usize) -> Option<PortIndex>
fn output(&self, node: NodeIndex, offset: usize) -> Option<PortIndex>
node. Read moresource§fn num_ports(&self, node: NodeIndex, direction: Direction) -> usize
fn num_ports(&self, node: NodeIndex, direction: Direction) -> usize
node in the given direction.source§fn port_offsets(
&self,
node: NodeIndex,
direction: Direction
) -> Self::NodePortOffsets<'_>
fn port_offsets( &self, node: NodeIndex, direction: Direction ) -> Self::NodePortOffsets<'_>
source§fn all_port_offsets(&self, node: NodeIndex) -> Self::NodePortOffsets<'_>
fn all_port_offsets(&self, node: NodeIndex) -> Self::NodePortOffsets<'_>
node in sequence.source§fn contains_node(&self, node: NodeIndex) -> bool
fn contains_node(&self, node: NodeIndex) -> bool
node.source§fn contains_port(&self, port: PortIndex) -> bool
fn contains_port(&self, port: PortIndex) -> bool
port.source§fn node_count(&self) -> usize
fn node_count(&self) -> usize
source§fn port_count(&self) -> usize
fn port_count(&self) -> usize
source§fn nodes_iter(&self) -> Self::Nodes<'_>
fn nodes_iter(&self) -> Self::Nodes<'_>
source§fn ports_iter(&self) -> Self::Ports<'_>
fn ports_iter(&self) -> Self::Ports<'_>
source§fn node_capacity(&self) -> usize
fn node_capacity(&self) -> usize
source§fn port_capacity(&self) -> usize
fn port_capacity(&self) -> usize
source§fn node_port_capacity(&self, node: NodeIndex) -> usize
fn node_port_capacity(&self, node: NodeIndex) -> usize
source§fn inputs(&self, node: NodeIndex) -> Self::NodePorts<'_>
fn inputs(&self, node: NodeIndex) -> Self::NodePorts<'_>
node. Read moresource§fn outputs(&self, node: NodeIndex) -> Self::NodePorts<'_>
fn outputs(&self, node: NodeIndex) -> Self::NodePorts<'_>
node. Read moresource§fn num_inputs(&self, node: NodeIndex) -> usize
fn num_inputs(&self, node: NodeIndex) -> usize
node. Read moresource§fn num_outputs(&self, node: NodeIndex) -> usize
fn num_outputs(&self, node: NodeIndex) -> usize
node. Read moresource§fn input_offsets(&self, node: NodeIndex) -> Self::NodePortOffsets<'_>
fn input_offsets(&self, node: NodeIndex) -> Self::NodePortOffsets<'_>
node. Read moresource§fn output_offsets(&self, node: NodeIndex) -> Self::NodePortOffsets<'_>
fn output_offsets(&self, node: NodeIndex) -> Self::NodePortOffsets<'_>
node. Read moreimpl StructuralPartialEq for MultiPortGraph
Auto Trait Implementations§
impl RefUnwindSafe for MultiPortGraph
impl Send for MultiPortGraph
impl Sync for MultiPortGraph
impl Unpin for MultiPortGraph
impl UnwindSafe for MultiPortGraph
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
§impl<T> Conv for T
impl<T> Conv for T
source§impl<G> DotFormat for Gwhere
G: LinkView,
impl<G> DotFormat for Gwhere
G: LinkView,
source§fn dot_format(&self) -> DotFormatter<'_, G>
fn dot_format(&self) -> DotFormatter<'_, G>
DotFormatter for the graph.source§fn dot_string(&self) -> String
fn dot_string(&self) -> String
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
source§impl<G> MermaidFormat for Gwhere
G: LinkView,
impl<G> MermaidFormat for Gwhere
G: LinkView,
source§fn mermaid_format(&self) -> MermaidFormatter<'_, G>
fn mermaid_format(&self) -> MermaidFormatter<'_, G>
MermaidFormatter for the graph. Read moresource§fn mermaid_string(&self) -> String
fn mermaid_string(&self) -> String
MermaidFormat::mermaid_format for more control over the output
style. Read more§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.