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>
impl<O, A> Hypergraph<O, A>
pub fn from_strict(h: Hypergraph<VecKind, O, A>) -> Self
pub fn discrete(nodes: Vec<O>) -> Self
Sourcepub fn new_node(&mut self, w: O) -> NodeId
pub fn new_node(&mut self, w: O) -> NodeId
Add a single node labeled w to the Hypergraph
Sourcepub fn new_edge(&mut self, x: A, interface: Hyperedge) -> EdgeId
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
Sourcepub fn new_operation(
&mut self,
x: A,
source_type: Vec<O>,
target_type: Vec<O>,
) -> (EdgeId, Interface)
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.
- For each element t of
source_type(resp.target_type), creates a node labeled t - 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.
Sourcepub fn unify(&mut self, v: NodeId, w: NodeId)
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.
Sourcepub fn add_edge_source(&mut self, edge_id: EdgeId, w: O) -> NodeId
pub fn add_edge_source(&mut self, edge_id: EdgeId, w: O) -> NodeId
Add a new source node labeled w to edge edge_id.
Sourcepub fn add_edge_target(&mut self, edge_id: EdgeId, w: O) -> NodeId
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 + PartialEq> Hypergraph<O, A>
impl<O: Clone + PartialEq, A: Clone + PartialEq> Hypergraph<O, A>
Sourcepub fn quotient(&mut self) -> FiniteFunction<VecKind>
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.
pub fn to_hypergraph(&self) -> Hypergraph<VecKind, O, A>
Source§impl<O, A> Hypergraph<O, A>
impl<O, A> Hypergraph<O, A>
Sourcepub fn coproduct_assign(&mut self, rhs: Hypergraph<O, A>)
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>
impl<O: Clone, A: Clone> Clone for Hypergraph<O, A>
Source§fn clone(&self) -> Hypergraph<O, A>
fn clone(&self) -> Hypergraph<O, A>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more