pub struct SimplicialComplex<N = Value, E = Value, M = Value> { /* private fields */ }Expand description
A simplicial complex (undirected, closed under faces).
Implementations§
Source§impl<N, E, M> SimplicialComplex<N, E, M>
impl<N, E, M> SimplicialComplex<N, E, M>
Sourcepub fn next_edge_id(&self) -> u64
pub fn next_edge_id(&self) -> u64
The id the next simplex added without an explicit id will get.
XGI parity: S._edge_uid.
Sourcepub fn update_uid_counter(&mut self, idx: u64)
pub fn update_uid_counter(&mut self, idx: u64)
Raise the counter past idx (see Hypergraph::update_uid_counter).
Sourcepub fn from_closed_simplices(
nodes: Vec<(String, N)>,
simplices: Vec<(String, Vec<String>, E)>,
) -> Result<Self, SimplexError>
pub fn from_closed_simplices( nodes: Vec<(String, N)>, simplices: Vec<(String, Vec<String>, E)>, ) -> Result<Self, SimplexError>
Rebuild a complex from its nodes and its simplices in id order, as
node_ids() and edge_ids() list them, adding no face: every subface
of size >= 2 of each simplex must be in the list. The first simplex
with a face missing gives SimplexError::NotClosed { idx }.
An entry is skipped, and the first one kept, when its id is already
taken or when its member set is already in the complex: the two cases
in which add_simplex is a no-op. No complex built by add_simplex
can list such an entry, so a state pickled from a real complex never
loses one here; only a hand-made list can.
Sourcepub fn node_attrs(&self, node_id: &str) -> Option<&N>
pub fn node_attrs(&self, node_id: &str) -> Option<&N>
A node’s attributes.
Sourcepub fn edge_attrs(&self, edge_id: &str) -> Option<&E>
pub fn edge_attrs(&self, edge_id: &str) -> Option<&E>
A simplex’s attributes.
Sourcepub fn add_node(&mut self, node_id: &str, attrs: N) -> bool
pub fn add_node(&mut self, node_id: &str, attrs: N) -> bool
Add a node (no simplices). XGI parity: S.add_node(id, **attr).
(Phase 4 Task 9 addition: the generator random_simplicial_complex
must add all N nodes up front regardless of which simplices are
sampled — XGI’s own generator does S.add_nodes_from(nodes) before
S.add_simplices_from(simplices). This method was not part of the
Phase-2 surface the Task-9 plan text assumed; it mirrors
Hypergraph::add_node exactly and required no other change.)
Sourcepub fn add_nodes_from(&mut self, nodes: impl IntoIterator<Item = (String, N)>)
pub fn add_nodes_from(&mut self, nodes: impl IntoIterator<Item = (String, N)>)
Add many nodes (no simplices). XGI parity: S.add_nodes_from(nbunch).
Sourcepub fn memberships(&self, node_id: &str) -> Option<Vec<String>>
pub fn memberships(&self, node_id: &str) -> Option<Vec<String>>
The ids of the simplices a node is a member of, in insertion order. XGI parity:
S.nodes.memberships(n).
Sourcepub fn node_duplicate_groups(&self) -> Vec<Vec<String>>
pub fn node_duplicate_groups(&self) -> Vec<Vec<String>>
Node ids with the same simplex-membership set, grouped over the whole complex: groups of two
or more, in order of first occurrence. XGI parity: S.nodes.duplicate_groups().
Sourcepub fn edge_duplicate_groups(&self) -> Vec<Vec<String>>
pub fn edge_duplicate_groups(&self) -> Vec<Vec<String>>
Simplex ids with the same member set, grouped over the whole complex (empty for a valid
complex). XGI parity: S.edges.duplicate_groups().
Sourcepub fn has_simplex(&self, members: &[String]) -> bool
pub fn has_simplex(&self, members: &[String]) -> bool
Whether a simplex with exactly these members is present (by member-set,
not id). XGI parity: S.has_simplex(simplex) (simplicialcomplex.py:783-806).
Sourcepub fn add_simplex(
&mut self,
members: Vec<String>,
idx: Option<String>,
attrs: E,
) -> Result<(), SimplexError>
pub fn add_simplex( &mut self, members: Vec<String>, idx: Option<String>, attrs: E, ) -> Result<(), SimplexError>
Add a simplex and all its missing subfaces (size >= 2). XGI parity:
S.add_simplex(members, idx, **attr) (simplicialcomplex.py:252-332).
Duplicate members or a duplicate idx are silent no-ops (deviation #5).
Sourcepub fn add_simplex_without_faces(
&mut self,
members: Vec<String>,
idx: Option<String>,
attrs: E,
) -> Result<(), SimplexError>
pub fn add_simplex_without_faces( &mut self, members: Vec<String>, idx: Option<String>, attrs: E, ) -> Result<(), SimplexError>
Add only the top simplex, leaving its subfaces out: the complex is not closed until
close runs. XGI does this by accident: add_simplices_from collects the
subfaces and adds them after its loop, so an error inside the loop leaves the simplices read
so far without their faces; the Python bindings mirror that state. Same no-op rules as
add_simplex.
Sourcepub fn add_edge(
&mut self,
_members: Vec<String>,
_idx: Option<String>,
_attrs: E,
) -> Result<(), SimplexError>
pub fn add_edge( &mut self, _members: Vec<String>, _idx: Option<String>, _attrs: E, ) -> Result<(), SimplexError>
add_edge is not available on a simplicial complex.
XGI parity: raises XGIError (simplicialcomplex.py:135-139).
Sourcepub fn remove_edge(&mut self, _edge_id: &str) -> Result<(), SimplexError>
pub fn remove_edge(&mut self, _edge_id: &str) -> Result<(), SimplexError>
remove_edge is not available on a simplicial complex.
XGI parity: raises XGIError (simplicialcomplex.py:153-157).
Sourcepub fn face_lattice(&self) -> &FaceLattice
pub fn face_lattice(&self) -> &FaceLattice
The lazily-computed face lattice (immediate-face relation), rebuilt on first access after a mutation.
Sourcepub fn add_simplices_from(
&mut self,
simplices: Vec<(Vec<String>, Option<String>, E)>,
)
pub fn add_simplices_from( &mut self, simplices: Vec<(Vec<String>, Option<String>, E)>, )
Add many simplices (each via add_simplex, so each closes under faces).
XGI parity: S.add_simplices_from(ebunch) — 3-tuple form
(simplicialcomplex.py:373-636).
Sourcepub fn close(&mut self)
pub fn close(&mut self)
Add all missing subfaces of every existing simplex.
XGI parity: S.close() (simplicialcomplex.py:638-662).
Sourcepub fn remove_simplex_id(&mut self, idx: &str) -> Result<(), SimplexError>
pub fn remove_simplex_id(&mut self, idx: &str) -> Result<(), SimplexError>
Remove a simplex AND every simplex that strictly contains it (its
supfaces), preserving closure. XGI parity: S.remove_simplex_id(idx)
(simplicialcomplex.py:726-756).
Sourcepub fn remove_simplex_ids_from(&mut self, ids: &[String])
pub fn remove_simplex_ids_from(&mut self, ids: &[String])
Remove several simplices by id (each with its supfaces).
Sourcepub fn copy(&self) -> Self
pub fn copy(&self) -> Self
An independent deep copy (face lattice recomputed lazily).
XGI parity: S.copy().
Trait Implementations§
Auto Trait Implementations§
impl<N = Value, E = Value, M = Value> !Freeze for SimplicialComplex<N, E, M>
impl<N = Value, E = Value, M = Value> !RefUnwindSafe for SimplicialComplex<N, E, M>
impl<N = Value, E = Value, M = Value> !Sync for SimplicialComplex<N, E, M>
impl<N, E, M> Forget for SimplicialComplex<N, E, M>
impl<N, E, M> Move for SimplicialComplex<N, E, M>
impl<N, E, M> Send for SimplicialComplex<N, E, M>
impl<N, E, M> Unpin for SimplicialComplex<N, E, M>
impl<N, E, M> UnsafeUnpin for SimplicialComplex<N, E, M>where
*const u8 is !null: UnsafeUnpin,
PhantomData<Node<Option<NodeKind<N, E>>>>: UnsafeUnpin,
PhantomData<Edge<Option<MembershipEdge<M>>>>: UnsafeUnpin,
PhantomData<Directed>: UnsafeUnpin,
PhantomData<usize>: UnsafeUnpin,
PhantomData<Bucket<String, NodeIndex>>: UnsafeUnpin,
PhantomData<(NodeIndex, String)>: UnsafeUnpin,
*const LeafNode<String, Value> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(String, Value)>>: UnsafeUnpin,
*const LeafNode<String, Vec<String>> is !null: UnsafeUnpin,
PhantomData<Box<(String, Vec<String>)>>: UnsafeUnpin,
impl<N, E, M> UnwindSafe for SimplicialComplex<N, E, M>where
RawVecInner: UnwindSafe,
N: UnwindSafe,
E: UnwindSafe,
M: UnwindSafe,
NonNull<u8>: UnwindSafe,
HashMap<NodeIndex, String>: UnwindSafe,
BTreeMap<String, Value>: UnwindSafe,
BTreeMap<String, Vec<String>>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§unsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.