Skip to main content

Topology

Struct Topology 

Source
pub struct Topology(/* private fields */);
Expand description

Topology.

This data type represents the topology of a graph, which allows to find the outgoing and incoming edges for each node in linear time by using efficient adjacency lists. Note that our implementation does not support edge weights, as they’re not necessary for scheduling purposes, and they would only add unnecessary complexity and overhead. The topology also contains the lazily computed Distance matrix that allows to find the shortest path between two nodes in the graph, or determine whether they’re reachable at all.

The graph topology must be considered immutable, as Adjacency lists can’t be mutated anyway, and represents the conversion of a graph into an executable form. In order to modify the graph, convert it back into a builder using the Graph::into_builder method.

The Topology data type is just a wrapper around [TopologyInner] with an Rc, so it can be shared between the Graph and Traversal structures without the need for lifetime annotations, which would render incremental and asynchronous traversals of graphs more complex.

Implementations§

Source§

impl Topology

Source

pub fn new(nodes: usize, edges: &[Edge]) -> Self

Creates a topology of the given graph.

This method constructs a topology from a graph builder, one of the key components of an executable Graph. Thus, it’s usually not needed to create a topology manually, as it’s automatically created when the graph is built using the [Builder::build] method.

§Examples
use zrx_graph::{Graph, Topology};

// Create graph builder and add nodes
let mut builder = Graph::builder();
let a = builder.add_node("a");
let b = builder.add_node("b");
let c = builder.add_node("c");

// Create edges between nodes
builder.add_edge(a, b)?;
builder.add_edge(b, c)?;

// Create topology
let topology = Topology::new(builder.len(), builder.edges());
Source§

impl Topology

Source

pub fn outgoing(&self) -> &Adjacency

Returns a reference to the outgoing edges.

Source

pub fn incoming(&self) -> &Adjacency

Returns a reference to the incoming edges.

Source

pub fn distance(&self) -> &Distance

Returns a reference to the distance matrix.

Trait Implementations§

Source§

impl Clone for Topology

Source§

fn clone(&self) -> Topology

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 Debug for Topology

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> 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.