Struct Hypergraph

Source
pub struct Hypergraph<O, A> {
    pub nodes: Vec<O>,
    pub edges: Vec<A>,
    pub adjacency: Vec<Hyperedge>,
    pub quotient: (Vec<NodeId>, Vec<NodeId>),
}
Expand description

A crate::lax::Hypergraph represents an “un-quotiented” hypergraph.

It can be thought of as a collection of disconnected operations and wires along with a quotient map which can be used with connected components to produce a Hypergraph.

Fields§

§nodes: Vec<O>

Node labels. Defines a finite map from NodeId to node label

§edges: Vec<A>

Edge labels. Defines a finite map from EdgeId to edge label

§adjacency: Vec<Hyperedge>

Hyperedges map an ordered list of source nodes to an ordered list of target nodes.

§quotient: (Vec<NodeId>, Vec<NodeId>)

Implementations§

Source§

impl<O, A> Hypergraph<O, A>

Source

pub fn empty() -> Self

The empty Hypergraph with no nodes or edges.

Source

pub fn is_strict(&self) -> bool

Check if the quotient map is empty: if so, then this is already a strict OpenHypergraph

Source

pub fn from_strict(h: Hypergraph<VecKind, O, A>) -> Self

Source

pub fn discrete(nodes: Vec<O>) -> Self

Source

pub fn new_node(&mut self, w: O) -> NodeId

Add a single node labeled w to the Hypergraph

Source

pub fn new_edge(&mut self, x: A, interface: Hyperedge) -> EdgeId

Add a single hyperedge labeled a to the Hypergraph it has sources and targets specified by interface return which EdgeId corresponds to that new hyperedge

Source

pub fn new_operation( &mut self, x: A, source_type: Vec<O>, target_type: Vec<O>, ) -> (EdgeId, Interface)

Append a “singleton” operation to the Hypergraph.

  1. For each element t of source_type (resp. target_type), creates a node labeled t
  2. creates An edge labeled x, and sets its source/target nodes to those from step (1)

Returns the index EdgeId of the operation in the Hypergraph, and its source and target nodes.

Source

pub fn unify(&mut self, v: NodeId, w: NodeId)

Identify a pair of nodes (v, w) by adding them to the quotient map.

Note that if the labels of v and w are not equal, then this will not represent a valid Hypergraph. This is intentional so that typechecking and type inference can be deferred until after construction of the Hypergraph.

Source

pub fn add_edge_source(&mut self, edge_id: EdgeId, w: O) -> NodeId

Add a new source node labeled w to edge edge_id.

Source

pub fn add_edge_target(&mut self, edge_id: EdgeId, w: O) -> NodeId

Add a new target node labeled w to edge edge_id

Source§

impl<O: Clone + PartialEq, A: Clone> Hypergraph<O, A>

Source

pub fn quotient(&mut self) -> FiniteFunction<VecKind>

Construct a Hypergraph by identifying nodes in the quotient map. Mutably quotient this Hypergraph, returning the coequalizer calculated from self.quotient.

NOTE: this operation is unchecked; you should verify quotiented nodes have the exact same type first, or this operation is undefined.

Source§

impl<O: Clone, A: Clone> Hypergraph<O, A>

Source

pub fn to_hypergraph(&self) -> Hypergraph<VecKind, O, A>

Source§

impl<O, A> Hypergraph<O, A>

Source

pub fn coproduct_assign(&mut self, rhs: Hypergraph<O, A>)

Compute the coproduct H₀ + H₁ by mutating the data of H₁

Trait Implementations§

Source§

impl<O: Clone, A: Clone> Clone for Hypergraph<O, A>

Source§

fn clone(&self) -> Hypergraph<O, A>

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<O: Debug, A: Debug> Debug for Hypergraph<O, A>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<O, A> Freeze for Hypergraph<O, A>

§

impl<O, A> RefUnwindSafe for Hypergraph<O, A>

§

impl<O, A> Send for Hypergraph<O, A>
where O: Send, A: Send,

§

impl<O, A> Sync for Hypergraph<O, A>
where O: Sync, A: Sync,

§

impl<O, A> Unpin for Hypergraph<O, A>
where O: Unpin, A: Unpin,

§

impl<O, A> UnwindSafe for Hypergraph<O, A>
where O: UnwindSafe, A: UnwindSafe,

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.