ReferenceRepresentation: The reference implementation of complexes

class simplicial.ReferenceRepresentation

A reference implementation for simplicial complexes.

This implementation is a direct in-memory representation of a simplicial complex. It is not minimal, in the sense that it holds the same information in different forms optimised to different uses. See Representing simplicial complexes for details.

Parameters

c – the complex we’re representing

Important

More useful methods for manipulating complexes are described under SimplicialComplex. The descriptions below are mainly for the aid of those wanting to write new representations

Complex

ReferenceRepresentation.setComplex(c)

Set the complex we’re representing. This allows the representation to make use of the complex’s more flexible operations if required.

Parameters

c (SimplicialComplex) – the complex

Adding and deleting simplices

ReferenceRepresentation.addSimplex(fs, id, attr)

Add a simplex to the complex whose faces are the elements of fs. This manipulates several internal dat a structures including the simplex list, face list, and boundary operator matrices.

Parameters
  • fs (List[Any]) – (optional) a list of faces of the simplex

  • id (Any) – (optional) name for the simplex

  • attr (Dict[str, Any]) – (optional) dict of attributes

Returns

the name of the new simplex

ReferenceRepresentation.newSimplex(d)

Generate a new unique identifier for a simplex. The default naming scheme uses a sequence number and a leading dimension indicator. Users can name simplices anything they want to get meaningful names.

Parameters

d (int) – dimension of the simplex to be identified

Return type

str

Returns

an identifier not currently used in the complex

ReferenceRepresentation.forceDeleteSimplex(s)

Delete a simplex without sanity checks. It delets the simplex, its attributes, and its entries in the appropriate boundary matrices.

Parameters

s (Any) – the simplex

ReferenceRepresentation.relabelSimplex(s, q)

Relabel a simplex. This changes the canonical mapping of simplices to indices as well as the simplex list.

Parameters
  • s (Any) – the simplex to rename

  • q (Any) – the new name

Retrieving simplices

ReferenceRepresentation.simplices(reverse)

Return all the simplices in the complex, in order: the low orders first (unless reverse is True), and in canonical order within each order.

Parameters

reverse (bool) – (optional) reverse the sort order if True

Return type

List[Any]

Returns

a list of simplices

ReferenceRepresentation.simplicesOfOrder(k)

Return all the simplices of the given order. The simplices are returned in “canonical” order, meaning the order they appear in the boiundary operator matrices.

Parameters

k (int) – the desired order

Return type

List[Any]

Returns

a set of simplices, which may be empty

ReferenceRepresentation.containsSimplex(s)

Test whether the complex contains the given simplex.

Parameters

s (Any) – the simplex

Return type

bool

Returns

True if the simplex is in the complex

ReferenceRepresentation.maxOrder()

Return the largest order of simplices in the complex.

Return type

int

Returns

the largest order that contains at least one simplex, or -1

Details of individual simplices

ReferenceRepresentation.orderOf(s)

Return the order of a simplex.

Parameters

s (Any) – the simplex

Return type

int

Returns

the order of the simplex

ReferenceRepresentation.indexOf(s)

Return the inmdex of a simplex.

Parameters

s (Any) – the simplex

Return type

int

Returns

an index

ReferenceRepresentation.getAttributes(s)

Return the attributes associated with the given simplex.

Parameters

s (Any) – the simplex

Return type

Dict[str, Any]

Returns

a dict of attributes

ReferenceRepresentation.setAttributes(s, attr)

Set the attributes associated with a simplex.

Parameters
  • s (Any) – the simplex

  • attr (Dict[str, Any]) – a dict of attributes

ReferenceRepresentation.faces(s)

Return the faces of a simplex.

Parameters

s (Any) – the simplex

Return type

Set[Any]

Returns

a set of faces

ReferenceRepresentation.cofaces(s)

Return the simplices the given simnplex is a face of.

Parameters

s (Any) – the simplex

Return type

Set[Any]

Returns

a list of simplices

ReferenceRepresentation.basisOf(s)

Return the basis of a simplex.

Parameters

s (Any) – the simplex

Return type

Set[Any]

Returns

the set of 0-simplices that form the basis of s

Topological information

ReferenceRepresentation.boundaryOperator(k)

Return the boundary operator of the k-simplices.

Parameters

k (int) – the order of simplices

Return type

ndarray

Returns

the boundary matrix

Optimised versions of core methods

ReferenceRepresentation.simplexWithBasis(bs, fatal=False)

Return the simplex with the given basis, if it exists in the complex. If no such simplex exists, or if the given set is not a basis, then None is returned; if fatal is True, then an exception is raised instead.

Parameters
  • bs (List[Any]) – the basis

  • fatal (bool) – (optional) make failure raise an exception (defaults to False)

Return type

Any

Returns

the simplex or None