toponetx.Complex#

class toponetx.Complex(**kwargs)[source]#

Bases: ABC

Abstract class representing a complex.

A complex is a space that is constructed by attaching lower-dimensional cells to a topological space to form a new space. The cells are attached to the space in a specific way, and the resulting space has a well-defined structure.

Example of complexes:

(1) Cell Complexes : Cell complexes can be used to represent various mathematical objects, such as graphs, manifolds, and discrete geometric shapes. They are useful in many areas of mathematics, such as algebraic topology and geometry, where they can be used to study the structure and properties of these objects.

(2) Simplicial Complexes : Simplicial complexes are mathematical structures used to study the topological properties of shapes and spaces. They are made up of a set of points called vertices, and a collection of simplices (triangles, tetrahedra, etc.) that are connected to each other in a specific way. Each simplex is formed by a subset of the vertices and is considered a building block of the complex. The properties of the complex are determined by the combinatorial arrangement of the simplices and their connectivity. Simplicial complexes are used in many areas of mathematics and computer science, such as geometric modeling, data analysis, and machine learning.

(3) The CombinatorialComplex class represents a combinatorial complex, which is a mathematical structure consisting of a set of points, a subset of the power set of points, and a ranking function that assigns a rank to each subset based on its size. These classes are used in many areas of mathematics and computer science, such as geometric modeling, data analysis, and machine learning.

Parameters:
**kwargskeyword arguments, optional

Attributes to add to the complex as key=value pairs.

Attributes:
complexdict

A dictionary that can be used to store additional information about the complex.

Methods

add_node(node)

Add node to the complex.

adjacency_matrix(rank[, signed, weight, index])

Return adjacency matrix of the complex.

clone()

Clone complex.

coadjacency_matrix(rank[, signed, weight, index])

Return coadjacency matrix of the complex.

incidence_matrix(rank[, signed, weight, index])

Return incidence matrix of the complex.

remove_nodes(node_set)

Remove the given nodes from the complex.

skeleton(rank)

Return the atoms of given rank in this complex.

__init__(**kwargs) None[source]#

Initialize a new instance of the Complex class.

Parameters:
**kwargskeyword arguments, optional

Attributes to add to the complex as key=value pairs.

Methods

__init__(**kwargs)

Initialize a new instance of the Complex class.

add_node(node)

Add node to the complex.

adjacency_matrix(rank[, signed, weight, index])

Return adjacency matrix of the complex.

clone()

Clone complex.

coadjacency_matrix(rank[, signed, weight, index])

Return coadjacency matrix of the complex.

incidence_matrix(rank[, signed, weight, index])

Return incidence matrix of the complex.

remove_nodes(node_set)

Remove the given nodes from the complex.

skeleton(rank)

Return the atoms of given rank in this complex.

Attributes

dim

Return dimension of the complex.

nodes

Return an iterator over the nodes in the complex.

shape

Return number of cells for each rank.

complex

abstract add_node(node: Hashable) None[source]#

Add node to the complex.

Parameters:
nodeHashable

The node to be added.

abstract adjacency_matrix(rank: int, signed: bool = True, weight: str | None = None, index: bool = False)[source]#

Return adjacency matrix of the complex.

Parameters:
rankint

The rank of the atoms to consider.

signedbool, default=True

If True, the adjacency matrix is signed, otherwise it is unsigned.

weightstr, optional

The name of the attribute to use as weights for the adjacency matrix.

indexbool, default=False

If True, the adjacency matrix is indexed by the atoms of the complex.

abstract clone() Self[source]#

Clone complex.

abstract coadjacency_matrix(rank: int, signed: bool = True, weight: str | None = None, index: bool = False)[source]#

Return coadjacency matrix of the complex.

Parameters:
rankint

The rank of the atoms to consider.

signedbool, default=True

If True, the adjacency matrix is signed, otherwise it is unsigned.

weightstr, optional

The name of the attribute to use as weights for the adjacency matrix.

indexbool, default=False

If True, the adjacency matrix is indexed by the atoms of the complex.

abstract property dim: int#

Return dimension of the complex.

Returns:
int

Returns the dimension of the complex.

abstract incidence_matrix(rank: int, signed: bool = True, weight: str | None = None, index: bool = False)[source]#

Return incidence matrix of the complex.

Parameters:
rankint

The rank of the atoms to consider.

signedbool, default=True

If True, the incidence matrix is signed, otherwise it is unsigned.

weightstr, optional

The name of the attribute to use as weights for the incidence matrix.

indexbool, default=False

If True, the incidence matrix is indexed by the nodes of the complex.

abstract property nodes: Iterator[Hashable]#

Return an iterator over the nodes in the complex.

Returns:
Iterator[Hashable]

Iterator over the nodes in the complex.

abstract remove_nodes(node_set: Iterator[Hashable]) None[source]#

Remove the given nodes from the complex.

Any elements that become invalid due to the removal of nodes are also removed.

Parameters:
node_setIterator[Hashable]

The nodes to be removed.

abstract property shape: tuple[int, ...]#

Return number of cells for each rank.

Returns:
tuple of ints

The number of elements for each rank. If the complex is empty, an empty tuple is returned.

abstract skeleton(rank: int)[source]#

Return the atoms of given rank in this complex.

Parameters:
rankint

The rank of the skeleton.