Skip to main content

SimplicialComplex

Struct SimplicialComplex 

Source
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>

Source

pub fn new() -> Self

Create an empty simplicial complex.

Source

pub fn next_edge_id(&self) -> u64

The id the next simplex added without an explicit id will get. XGI parity: S._edge_uid.

Source

pub fn update_uid_counter(&mut self, idx: u64)

Raise the counter past idx (see Hypergraph::update_uid_counter).

Source

pub fn from_closed_simplices( nodes: Vec<(String, N)>, simplices: Vec<(String, Vec<String>, E)>, ) -> Result<Self, SimplexError>
where N: Default, E: Default, M: Default + Clone,

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.

Source

pub fn num_nodes(&self) -> usize

Number of nodes. XGI parity: S.num_nodes.

Source

pub fn num_edges(&self) -> usize

Number of simplices. XGI parity: S.num_edges.

Source

pub fn has_node(&self, node_id: &str) -> bool

Whether a node exists.

Source

pub fn has_edge(&self, edge_id: &str) -> bool

Whether a simplex id exists.

Source

pub fn members(&self, edge_id: &str) -> Option<Vec<String>>

The members of a simplex (by id).

Source

pub fn node_attrs(&self, node_id: &str) -> Option<&N>

A node’s attributes.

Source

pub fn edge_attrs(&self, edge_id: &str) -> Option<&E>

A simplex’s attributes.

Source

pub fn node_ids(&self) -> Vec<String>

All node ids (insertion order).

Source

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.)

Source

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).

Source

pub fn edge_ids(&self) -> Vec<String>

All simplex ids (insertion order).

Source

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).

Source

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().

Source

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().

Source

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).

Source

pub fn add_simplex( &mut self, members: Vec<String>, idx: Option<String>, attrs: E, ) -> Result<(), SimplexError>
where N: Default, E: Default, M: Default + Clone,

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).

Source

pub fn add_simplex_without_faces( &mut self, members: Vec<String>, idx: Option<String>, attrs: E, ) -> Result<(), SimplexError>
where N: Default, E: Default, M: Default + Clone,

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.

Source

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).

Source

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).

Source

pub fn face_lattice(&self) -> &FaceLattice

The lazily-computed face lattice (immediate-face relation), rebuilt on first access after a mutation.

Source

pub fn add_simplices_from( &mut self, simplices: Vec<(Vec<String>, Option<String>, E)>, )
where N: Default, E: Default, M: Default + Clone,

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).

Source

pub fn close(&mut self)
where N: Default, E: Default, M: Default + Clone,

Add all missing subfaces of every existing simplex. XGI parity: S.close() (simplicialcomplex.py:638-662).

Source

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).

Source

pub fn remove_simplex_ids_from(&mut self, ids: &[String])

Remove several simplices by id (each with its supfaces).

Source

pub fn copy(&self) -> Self
where N: Clone, E: Clone, M: Clone,

An independent deep copy (face lattice recomputed lazily). XGI parity: S.copy().

Source

pub fn freeze(&mut self)

Freeze against modification (via the inner hypergraph’s frozen guard). XGI parity: S.freeze().

Source

pub fn is_frozen(&self) -> bool

Whether the complex is frozen. XGI parity: S.is_frozen.

Trait Implementations§

Source§

impl<N, E, M> Default for SimplicialComplex<N, E, M>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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>
where M: Send, E: Send, N: Send, RawVecInner: Send, RawTable<usize>: Send, RawTable<(NodeIndex, String)>: Send, NodeRef<Owned, String, Value, LeafOrInternal>: Send, BoxRaw<(String, Value)>: Send, NodeRef<Owned, String, Vec<String>, LeafOrInternal>: Send, BoxRaw<(String, Vec<String>)>: Send,

§

impl<N, E, M> Unpin for SimplicialComplex<N, E, M>
where M: Unpin, E: Unpin, N: Unpin, *const u8 is !null: Unpin, *const LeafNode<String, Value> is !null: Unpin, Box<(String, Value)>: Unpin, *const LeafNode<String, Vec<String>> is !null: Unpin, Box<(String, Vec<String>)>: Unpin,

§

impl<N, E, M> UnsafeUnpin for SimplicialComplex<N, E, M>

§

impl<N, E, M> UnwindSafe for SimplicialComplex<N, E, M>

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

unsafe fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.