Struct OpenHypergraph

Source
pub struct OpenHypergraph<O, A> {
    pub sources: Vec<NodeId>,
    pub targets: Vec<NodeId>,
    pub hypergraph: Hypergraph<O, A>,
}
Expand description

A lax OpenHypergraph is a cospan of lax hypergraphs: a hypergraph equipped with two finite maps representing the interfaces.

Fields§

§sources: Vec<NodeId>§targets: Vec<NodeId>§hypergraph: Hypergraph<O, A>

Implementations§

Source§

impl<O, A> OpenHypergraph<O, A>

Source

pub fn tensor_assign(&mut self, rhs: OpenHypergraph<O, A>)

Compute the tensor product f.tensor(g) by mutating the data of f

Source§

impl<O, A> OpenHypergraph<O, A>

Source

pub fn empty() -> Self

The empty OpenHypergraph with no nodes and no edges.

In categorical terms, this is the identity map at the unit object.

Source

pub fn from_strict(f: OpenHypergraph<VecKind, O, A>) -> Self

Source

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

Create a new node in the hypergraph labeled w.

Source

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

Source

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

Create a new “operation” in the hypergraph. Concretely, f.new_operation(x, s, t) mutates f by adding:

  1. a new hyperedge labeled x
  2. len(s) new nodes, with the ith node labeled s[i]
  3. len(t) new nodes, with the ith node labeled t[i]

Returns the new hyperedge ID and the NodeIds of the source/target nodes.

This is a convenience wrapper for Hypergraph::new_operation

Source

pub fn singleton(x: A, source_type: Vec<O>, target_type: Vec<O>) -> Self

An OpenHypergraph consisting of a single operation.

Source

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

Compute an open hypergraph by calling to_hypergraph on the internal Hypergraph.

Source

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

Source

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

Source§

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

Source

pub fn quotient(&mut self)

Apply the quotient map to identify nodes in the internal Hypergraph. This deletes the internal quotient map, resulting in a strict OpenHypergraph.

Source

pub fn to_open_hypergraph(self) -> OpenHypergraph<VecKind, O, A>

Convert this lax OpenHypergraph to a strict crate::strict::OpenHypergraph by quotienting.

Trait Implementations§

Source§

impl<O: Clone + PartialEq, A: Clone> Arrow for OpenHypergraph<O, A>

Source§

type Object = Vec<O>

Source§

fn source(&self) -> Self::Object

Source§

fn target(&self) -> Self::Object

Source§

fn identity(a: Self::Object) -> Self

the identity morphism on a
Source§

fn compose(&self, other: &Self) -> Option<Self>

Compose morphisms in diagrammatic order: self ; other Read more
Source§

impl<O: Clone + PartialEq, A: Clone> BitOr<&OpenHypergraph<O, A>> for &OpenHypergraph<O, A>

Source§

type Output = OpenHypergraph<O, A>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: &OpenHypergraph<O, A>) -> Self::Output

Performs the | operation. Read more
Source§

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

Source§

fn clone(&self) -> OpenHypergraph<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 OpenHypergraph<O, A>

Source§

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

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

impl<O: Clone + PartialEq, A: Clone> Monoidal for OpenHypergraph<O, A>

Source§

fn unit() -> Self::Object

the monoidal unit object
Source§

fn tensor(&self, other: &Self) -> Self

f \otimes g of two morphisms
Source§

impl<O: Clone + PartialEq, A: Clone> Shr<&OpenHypergraph<O, A>> for &OpenHypergraph<O, A>

Source§

type Output = Option<OpenHypergraph<O, A>>

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: &OpenHypergraph<O, A>) -> Self::Output

Performs the >> operation. Read more
Source§

impl<O: Clone + PartialEq, A: Clone + PartialEq> Spider<VecKind> for OpenHypergraph<O, A>

Source§

fn dagger(&self) -> Self

Given an Arrow with type f : A → B, construct its dagger f† : B → A by using Hypergraph structure to bend sources to targets and vice-versa.
Source§

fn spider( s: FiniteFunction<VecKind>, t: FiniteFunction<VecKind>, w: Self::Object, ) -> Option<Self>

Construct a spider using a type w, and source s and target t interface maps.
Source§

fn half_spider(s: FiniteFunction<K>, w: Self::Object) -> Option<Self>

Construct a “half-spider”: a spider whose t leg is identity.
Source§

impl<O: Clone + PartialEq, A: Clone + PartialEq> SymmetricMonoidal for OpenHypergraph<O, A>

Source§

fn twist(a: Self::Object, b: Self::Object) -> Self

Construct the symmetry \sigma_{a,b} from a and b.

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<O, A> UnwindSafe for OpenHypergraph<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.