Skip to main content

Topology

Struct Topology 

Source
pub struct Topology<R = Direct> { /* 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. Our implementation does not support edge weights, as they would add unnecessary complexity and overhead.

Topologies can be Direct and Transitive, the latter of which allows to determine whether one node is reachable from another. The Direct topology is the default, and can be converted on-demand.

Implementations§

Source§

impl Topology<Direct>

Source

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

Creates a topology of the given graph.

This method constructs a topology from a graph’s nodes and edges, and is the key component of an executable Graph. 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

pub fn into_transitive(self) -> Topology<Transitive>

Converts this topology into one with transitive reachability.

§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 transitive topology
let topology = Topology::new(builder.len(), builder.edges())
    .into_transitive();
Source§

impl Topology<Transitive>

Source

pub fn has_path(&self, source: usize, target: usize) -> bool

Returns whether there is a path from the source to the target.

Source§

impl<R> Topology<R>

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.

Trait Implementations§

Source§

impl<R> Clone for Topology<R>

Source§

fn clone(&self) -> Self

Clones the topology.

1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<R: Debug> Debug for Topology<R>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<R> Eq for Topology<R>

Source§

impl<R> PartialEq for Topology<R>

Source§

fn eq(&self, other: &Self) -> bool

Compares two topologies for equality.

§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 and compare topologies
let topology = Topology::new(builder.len(), builder.edges());
assert_eq!(topology, topology.clone());
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

§

impl<R> Freeze for Topology<R>

§

impl<R> RefUnwindSafe for Topology<R>
where R: RefUnwindSafe,

§

impl<R> Send for Topology<R>
where R: Sync + Send,

§

impl<R> Sync for Topology<R>
where R: Sync + Send,

§

impl<R> Unpin for Topology<R>

§

impl<R> UnsafeUnpin for Topology<R>

§

impl<R> UnwindSafe for Topology<R>
where R: 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> 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.