Struct Network

Source
pub struct Network<'a, G>(/* private fields */);
Expand description

The network graph adaptor.

It is meant to be used by borrowing the underlying graph. (also see the module description adapters::network).

let g = classes::cycle::<LinkedListGraph>(5);
let n = Network::new(&g);

The network inherits all trait implementations from the underlying graph. In particular, if the underlying graph implements IndexGraph then nodes and edges of the network are numbered, too:

  • The node_id is the same as in the underlying graph,
  • the edge with id i is mapped to the edges 2*i (forward edge) and 2*i+1 (backward edge).

Implementations§

Source§

impl<'a, G> Network<'a, G>
where G: GraphType,

Source

pub fn new(g: &'a G) -> Self

Create a new network adapter wrapping g.

Source

pub fn as_graph(&self) -> &'a G

Return a reference to the underlying graph.

Source

pub fn from_edge<'g>(&self, e: G::Edge<'g>) -> NetworkEdge<G::Edge<'g>>

Return the forward edge corresponding the edge e in the underlying graph.

Trait Implementations§

Source§

impl<'a, G> Clone for Network<'a, G>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'g, G> Directed for Network<'g, G>
where G: Directed,

Source§

type OutIt<'a> = NetworkOutIt<<G as Directed>::IncidentIt<'a>> where G: 'a, 'g: 'a

Type of a graph iterator over edges leaving a node.
Source§

type InIt<'a> = NetworkInIt<<G as Directed>::IncidentIt<'a>> where G: 'a, 'g: 'a

Type of a graph iterator over edges entering a node.
Source§

type IncidentIt<'a> = NetworkIncidentIt<<G as Directed>::IncidentIt<'a>, (<G as Directed>::DirectedEdge<'a>, <G as GraphType>::Node<'a>)> where G: 'a, 'g: 'a

Type of an iterator over all incident edges.
Source§

type DirectedEdge<'a> = NetworkDirectedEdge<<Network<'g, G> as GraphType>::Edge<'a>> where Self: 'a

Type of a directed edge.
Source§

fn out_iter(&self, u: Self::Node<'_>) -> Self::OutIt<'_>

Return a graph iterator over the edges leaving a node.
Source§

fn in_iter(&self, u: Self::Node<'_>) -> Self::InIt<'_>

Return a graph iterator over the edges leaving a node.
Source§

fn incident_iter(&self, u: Self::Node<'_>) -> Self::IncidentIt<'_>

Return an iterator over all directed edges incident with a node.
Source§

fn outedges( &self, u: Self::Node<'_>, ) -> GraphIter<'_, Self, <Self as Directed>::OutIt<'_>>
where Self: Sized,

Return an iterator over the edges leaving a node.
Source§

fn outgoing(&self) -> OutEdges<'_, Self>
where Self: Sized,

Return access to the outgoing arcs via an Adjacencies trait. Read more
Source§

fn inedges( &self, u: Self::Node<'_>, ) -> GraphIter<'_, Self, <Self as Directed>::InIt<'_>>
where Self: Sized,

Return an iterator over the edges leaving a node.
Source§

fn incoming(&self) -> InEdges<'_, Self>
where Self: Sized,

Return access to the incoming arcs via an Adjacencies trait. Read more
Source§

fn incident_edges( &self, u: Self::Node<'_>, ) -> GraphIter<'_, Self, <Self as Directed>::IncidentIt<'_>>
where Self: Sized,

Return an iterator over all directed edges incident with a node.
Source§

impl<'a, G> DirectedRef<'a> for Network<'a, G>
where G: 'a + Directed,

Source§

type OutIt = NetworkOutIt<<G as Directed>::IncidentIt<'a>>

Type of a graph iterator over edges leaving a node.
Source§

type InIt = NetworkInIt<<G as Directed>::IncidentIt<'a>>

Type of a graph iterator over edges entering a node.
Source§

type IncidentIt = NetworkIncidentIt<<G as Directed>::IncidentIt<'a>, (<G as Directed>::DirectedEdge<'a>, <G as GraphType>::Node<'a>)>

Type of an iterator over all incident edges.
Source§

type DirectedEdge = NetworkDirectedEdge<<Network<'a, G> as GraphTypeRef<'a>>::Edge>

Type of a directed edge.
Source§

fn out_iter(&self, u: Self::Node) -> Self::OutIt

Return the source node of an edge. Return the sink node of an edge. Return a graph iterator over the edges leaving a node.
Source§

fn in_iter(&self, u: Self::Node) -> Self::InIt

Return a graph iterator over the edges leaving a node.
Source§

fn incident_iter(&self, u: Self::Node) -> Self::IncidentIt

Return an iterator over all directed edges incident with a node.
Source§

fn outedges(&self, u: Self::Node) -> GraphIter<'_, Self, Self::OutIt>
where Self: Sized,

Return an iterator over the edges leaving a node.
Source§

fn inedges(&self, u: Self::Node) -> GraphIter<'_, Self, Self::InIt>
where Self: Sized,

Return an iterator over the edges leaving a node.
Source§

fn incident_edges(&self, u: Self::Node) -> GraphIter<'_, Self, Self::IncidentIt>
where Self: Sized,

Return an iterator over all directed edges incident with a node.
Source§

impl<'g, G> FiniteDigraph for Network<'g, G>
where G: FiniteDigraph,

Source§

fn src(&self, e: Self::Edge<'_>) -> Self::Node<'_>

Return the source node of an edge.
Source§

fn snk(&self, e: Self::Edge<'_>) -> Self::Node<'_>

Return the sink node of an edge.
Source§

impl<'a, G> FiniteDigraphRef<'a> for Network<'a, G>
where G: FiniteDigraph,

Source§

fn src(&self, e: Self::Edge) -> Self::Node

Source§

fn snk(&self, e: Self::Edge) -> Self::Node

Source§

impl<'g, G> FiniteGraph for Network<'g, G>
where G: FiniteGraph,

Source§

type NodeIt<'a> = NetworkNodeIt<<G as FiniteGraph>::NodeIt<'a>> where G: 'a, 'g: 'a

Type of an iterator over all nodes.
Source§

type EdgeIt<'a> = NetworkEdgeIt<G, <G as FiniteGraph>::EdgeIt<'a>> where G: 'a, 'g: 'a

Type of an iterator over all edges.
Source§

fn num_nodes(&self) -> usize

Return the number of nodes in the graph.
Source§

fn num_edges(&self) -> usize

Return the number of edges in the graph.
Source§

fn nodes_iter(&self) -> Self::NodeIt<'_>

Return a graph iterator over all nodes.
Source§

fn edges_iter(&self) -> Self::EdgeIt<'_>

Return a graph iterator over all edges. Read more
Source§

fn enodes(&self, e: Self::Edge<'_>) -> (Self::Node<'_>, Self::Node<'_>)

Return the nodes connected by an edge. Read more
Source§

fn nodes(&self) -> NodeIterator<'_, Self>
where Self: Sized,

Return an iterator over all nodes.
Source§

fn edges(&self) -> EdgeIterator<'_, Self>
where Self: Sized,

Return an iterator over all edges. Read more
Source§

impl<'a, G> FiniteGraphRef<'a> for Network<'a, G>
where G: FiniteGraph,

Source§

type NodeIt = NetworkNodeIt<<G as FiniteGraph>::NodeIt<'a>>

Type of an iterator over all nodes.
Source§

type EdgeIt = NetworkEdgeIt<G, <G as FiniteGraph>::EdgeIt<'a>>

Type of an iterator over all edges.
Source§

fn num_nodes(&self) -> usize

Return the number of nodes in the graph.
Source§

fn num_edges(&self) -> usize

Return the number of edges in the graph.
Source§

fn nodes_iter(&self) -> Self::NodeIt

Return a graph iterator over all nodes.
Source§

fn edges_iter(&self) -> Self::EdgeIt

Return a graph iterator over all edges. Read more
Source§

fn enodes(&self, e: Self::Edge) -> (Self::Node, Self::Node)

Return the nodes connected by an edge. Read more
Source§

fn nodes(&self) -> GraphIter<'_, Self, Self::NodeIt>
where Self: Sized,

Return an iterator over all nodes.
Source§

fn edges(&self) -> GraphIter<'_, Self, Self::EdgeIt>
where Self: Sized,

Return an iterator over all edges. Read more
Source§

impl<'a, G, I> GraphIterator<Network<'a, G>> for NetworkEdgeIt<G, I>
where I: GraphIterator<G>, I::Item: Clone,

Source§

type Item = NetworkEdge<<I as GraphIterator<G>>::Item>

Source§

fn next(&mut self, net: &Network<'a, G>) -> Option<Self::Item>

Source§

fn size_hint(&self, net: &Network<'a, G>) -> (usize, Option<usize>)

Source§

fn count(self, net: &Network<'a, G>) -> usize

Source§

fn iter(self, g: &G) -> GraphIter<'_, G, Self>
where G: Sized,

Source§

impl<'a, G, I, N, D> GraphIterator<Network<'a, G>> for NetworkInIt<I>
where I: GraphIterator<G, Item = (D, N)>, D: DirectedEdge,

Source§

type Item = (NetworkEdge<<D as DirectedEdge>::Edge>, N)

Source§

fn next(&mut self, net: &Network<'a, G>) -> Option<Self::Item>

Source§

fn size_hint(&self, net: &Network<'a, G>) -> (usize, Option<usize>)

Source§

fn count(self, net: &Network<'a, G>) -> usize

Source§

fn iter(self, g: &G) -> GraphIter<'_, G, Self>
where G: Sized,

Source§

impl<'a, G, I, N, D> GraphIterator<Network<'a, G>> for NetworkIncidentIt<I, I::Item>
where I: GraphIterator<G, Item = (D, N)>, N: Clone, D: DirectedEdge + Clone,

Source§

type Item = (NetworkDirectedEdge<NetworkEdge<<D as DirectedEdge>::Edge>>, N)

Source§

fn next(&mut self, net: &Network<'a, G>) -> Option<Self::Item>

Source§

fn size_hint(&self, net: &Network<'a, G>) -> (usize, Option<usize>)

Source§

fn count(self, net: &Network<'a, G>) -> usize

Source§

fn iter(self, g: &G) -> GraphIter<'_, G, Self>
where G: Sized,

Source§

impl<'a, G, I, N, E> GraphIterator<Network<'a, G>> for NetworkNeighIt<G, I>
where N: Clone, E: Clone, I: GraphIterator<G, Item = (E, N)>,

Source§

type Item = (NetworkEdge<E>, N)

Source§

fn next(&mut self, net: &Network<'a, G>) -> Option<Self::Item>

Source§

fn size_hint(&self, net: &Network<'a, G>) -> (usize, Option<usize>)

Source§

fn count(self, net: &Network<'a, G>) -> usize

Source§

fn iter(self, g: &G) -> GraphIter<'_, G, Self>
where G: Sized,

Source§

impl<'a, G, I> GraphIterator<Network<'a, G>> for NetworkNodeIt<I>
where I: GraphIterator<G>,

Source§

type Item = <I as GraphIterator<G>>::Item

Source§

fn next(&mut self, net: &Network<'a, G>) -> Option<Self::Item>

Source§

fn size_hint(&self, net: &Network<'a, G>) -> (usize, Option<usize>)

Source§

fn count(self, net: &Network<'a, G>) -> usize

Source§

fn iter(self, g: &G) -> GraphIter<'_, G, Self>
where G: Sized,

Source§

impl<'a, G, I, N, D> GraphIterator<Network<'a, G>> for NetworkOutIt<I>
where I: GraphIterator<G, Item = (D, N)>, D: DirectedEdge,

Source§

type Item = (NetworkEdge<<D as DirectedEdge>::Edge>, N)

Source§

fn next(&mut self, net: &Network<'a, G>) -> Option<Self::Item>

Source§

fn size_hint(&self, net: &Network<'a, G>) -> (usize, Option<usize>)

Source§

fn count(self, net: &Network<'a, G>) -> usize

Source§

fn iter(self, g: &G) -> GraphIter<'_, G, Self>
where G: Sized,

Source§

impl<'g, G> GraphType for Network<'g, G>
where G: GraphType,

Source§

type Node<'a> = <G as GraphType>::Node<'a>

Type of a node.
Source§

type Edge<'a> = NetworkEdge<<G as GraphType>::Edge<'a>>

Type of an edge.
Source§

impl<'a, G> GraphTypeRef<'a> for Network<'a, G>
where G: GraphType,

Source§

type Node = <G as GraphType>::Node<'a>

Type of a node.
Source§

type Edge = NetworkEdge<<G as GraphType>::Edge<'a>>

Type of an edge.
Source§

impl<'g, G> IndexGraph for Network<'g, G>
where G: IndexGraph,

Source§

fn node_id(&self, u: Self::Node<'_>) -> usize

Return a unique id associated with a node.
Source§

fn edge_id(&self, e: Self::Edge<'_>) -> usize

Return a unique id associated with an edge. Read more
Source§

fn id2node(&self, id: usize) -> Self::Node<'_>

Return the node associated with the given id. Read more
Source§

fn id2edge(&self, id: usize) -> Self::Edge<'_>

Return the edge associated with the given id. Read more
Source§

impl<'a, G> IndexGraphRef<'a> for Network<'a, G>
where G: IndexGraph,

Source§

fn node_id(&self, u: Self::Node) -> usize

Return a unique id associated with a node.
Source§

fn edge_id(&self, e: Self::Edge) -> usize

Return a unique id associated with an edge. Read more
Source§

fn id2node(&self, id: usize) -> Self::Node

Return the node associated with the given id. Read more
Source§

fn id2edge(&self, id: usize) -> Self::Edge

Return the edge associated with the given id. Read more
Source§

impl<'g, G> Undirected for Network<'g, G>
where G: Undirected,

Source§

type NeighIt<'a> = NetworkNeighIt<G, <G as Undirected>::NeighIt<'a>> where G: 'a, 'g: 'a

Type of a graph iterator over all incident edges.
Source§

fn neigh_iter(&self, u: Self::Node<'_>) -> Self::NeighIt<'_>

Return a graph iterator over the edges adjacent to some node.
Source§

fn neighs( &self, u: Self::Node<'_>, ) -> GraphIter<'_, Self, <Self as Undirected>::NeighIt<'_>>
where Self: Sized,

Return an iterator over the edges adjacent to some node.
Source§

fn neighbors(&self) -> Neighbors<'_, Self>
where Self: Sized,

Return access to the neighbors via an Adjacencies trait. Read more
Source§

impl<'a, G> UndirectedRef<'a> for Network<'a, G>
where G: Undirected,

Source§

type NeighIt = NetworkNeighIt<G, <G as Undirected>::NeighIt<'a>>

Type of a graph iterator over all incident edges.
Source§

fn neigh_iter(&self, u: Self::Node) -> Self::NeighIt

Return a graph iterator over the edges adjacent to some node.
Source§

fn neighs(&self, u: Self::Node) -> GraphIter<'_, Self, Self::NeighIt>
where Self: Sized,

Return an iterator over the edges adjacent to some node.
Source§

impl<'a, G: Copy> Copy for Network<'a, G>

Auto Trait Implementations§

§

impl<'a, G> Freeze for Network<'a, G>

§

impl<'a, G> RefUnwindSafe for Network<'a, G>
where G: RefUnwindSafe,

§

impl<'a, G> Send for Network<'a, G>
where G: Sync,

§

impl<'a, G> Sync for Network<'a, G>
where G: Sync,

§

impl<'a, G> Unpin for Network<'a, G>

§

impl<'a, G> UnwindSafe for Network<'a, G>
where G: RefUnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<G> Digraph for G

Source§

impl<G> Graph for G

Source§

impl<T> IndexDigraph for T
where T: IndexGraph + Digraph,