2.3. ECT on Graphs

class ect.ect_graph.ECT(num_dirs, num_thresh, bound_radius=None)[source]

A class to calculate the Euler Characteristic Transform (ECT) from an input EmbeddedGraph or EmbeddedCW.

The result is a matrix where entry M[i,j] is \(\chi(K_{a_i})\) for the direction \(\omega_j\) where \(a_i\) is the ith entry in self.threshes, and \(\omega_j\) is the ith entry in self.thetas.

Attributes
num_dirs (int):

The number of directions to consider in the matrix.

num_thresh (int):

The number of thresholds to consider in the matrix.

bound_radius (int):

Either None, or a positive radius of the bounding circle.

ECT_matrix (np.array):

The matrix to store the ECT.

SECT_matrix (np.array):

The matrix to store the SECT.

__init__(num_dirs, num_thresh, bound_radius=None)[source]

Constructs all the necessary attributes for the ECT object.

Parameters:
  • num_dirs (int) – The number of directions to consider in the matrix.

  • num_thresh (int) – The number of thresholds to consider in the matrix.

  • bound_radius (int) – Either None, or a positive radius of the bounding circle.

set_bounding_radius(bound_radius)[source]

Manually sets the radius of the bounding circle centered at the origin for the ECT object.

Parameters:

bound_radius (int) – Either None, or a positive radius of the bounding circle.

get_radius_and_thresh(G, bound_radius)[source]

An internally used function to get the bounding radius and thresholds for the ECT calculation.

Parameters:
  • G (EmbeddedGraph / EmbeddedCW) – The input graph to calculate the ECT for.

  • bound_radius (float) – If None, uses the following in order: (i) the bounding radius stored in the class; or if not available (ii) the bounding radius of the given graph. Otherwise, should be a postive float \(R\) where the ECC will be computed at thresholds in \([-R,R]\). Default is None.

Returns:

float, np.array

The bounding radius and the thresholds for the ECT calculation.

get_ECT()[source]

Returns the ECT matrix.

get_SECT()[source]

Returns the SECT matrix.

calculateECC(G, theta, bound_radius=None, return_counts=False)[source]

Function to compute the Euler Characteristic Curve (ECC) of an EmbeddedGraph.

Parameters:
  • G (nx.Graph) – The graph to compute the ECC for.

  • theta (float) – The angle (in radians) for the direction function.

  • bound_radius (float, optional) – Radius for threshold range. Default is None.

  • return_counts (bool, optional) – Whether to return vertex, edge, and face counts. Default is False.

Returns:

ECC values at each threshold. (Optional) Tuple of counts: (ecc, vertex_count, edge_count, face_count)

Return type:

numpy.ndarray

calculateECT(graph, bound_radius=None, compute_SECT=True)[source]

Calculates the ECT from an input either EmbeddedGraph or EmbeddedCW. The entry M[i,j] is \(\chi(K_{a_j})\) for the direction \(\omega_i\) where \(a_j\) is the jth entry in self.threshes, and \(\omega_i\) is the ith entry in self.thetas.

Parameters:
  • graph (EmbeddedGraph/EmbeddedCW) – The input graph to calculate the ECT from.

  • bound_radius (float) – If None, uses the following in order: (i) the bounding radius stored in the class; or if not available (ii) the bounding radius of the given graph. Otherwise, should be a postive float \(R\) where the ECC will be computed at thresholds in \([-R,R]\). Default is None.

  • compute_SECT (bool) – Whether to compute the SECT after the ECT is computed. Default is True. Sets the SECT_matrix attribute, but doesn’t return it. Can be returned with the get_SECT method.

Returns:

np.array

The matrix representing the ECT of size (num_dirs,num_thresh).

calculateSECT()[source]

Function to calculate the Smooth Euler Characteristic Transform (SECT) from the ECT matrix.

Returns:

np.array

The matrix representing the SECT of size (num_dirs,num_thresh).

plotECC(graph, theta, bound_radius=None, draw_counts=False)[source]

Function to plot the Euler Characteristic Curve (ECC) for a specific direction theta. Note that this calculates the ECC for the input graph and then plots it.

Parameters:
  • graph (EmbeddedGraph/EmbeddedCW) – The input graph or CW complex.

  • theta (float) – The angle in \([0,2\pi]\) for the direction to plot the ECC.

  • bound_radius (float) – If None, uses the following in order: (i) the bounding radius stored in the class; or if not available (ii) the bounding radius of the given graph. Otherwise, should be a postive float \(R\) where the ECC will be computed at thresholds in \([-R,R]\). Default is None.

  • draw_counts (bool) – Whether to draw the counts of vertices, edges, and faces varying across thresholds. Default is False.

plotECT()[source]

Function to plot the Euler Characteristic Transform (ECT) matrix. Note that the ECT matrix must be calculated before calling this function.

The resulting plot will have the angle on the x-axis and the threshold on the y-axis.

plotSECT()[source]

Function to plot the Smooth Euler Characteristic Transform (SECT) matrix. Note that the SECT matrix must be calculated before calling this function.

The resulting plot will have the angle on the x-axis and the threshold on the y-axis.

plot(plot_type)[source]

Function to plot the ECT or SECT matrix. The type parameter should be either ‘ECT’ or ‘SECT’.

Parameters:

plot_type – str The type of plot to make. Either ‘ECT’ or ‘SECT’.