Process math¶
This folder contains all the functions that designate the mathematical part of the project. This part uses modular arithmetic and the structure of the graph, which is defined by vertices and edges who are represented by adjacency matrices.
Graph¶
-
class
process_math.Graph.Graph(table_number, modulo_number)¶ Graph class is used to contain modular multiplication related specifications and to create the associated undirected graph in the console.
- Parameters
N (float) – Corresponds to the multiplication table assigned by the user. This number is rounded to \(10^{-2}\)
mod (int) – Corresponds to the modulo number entered by the user
M (scipy.sparse.coo.coo_matrix) – Adjacency sparse matrix used to represent the graph. The dimension of this matrix is (mod*100, mod*100) whose non-diagonal element \(m_{ij}\) corresponds to an edge between vertex i and vertex j
-
process_math.Graph.Graph.__init__(self, table_number, modulo_number)¶ Constructor method. This method instantiates a graph from the parameters.
-
process_math.Graph.Graph.print_matrix(self)¶ Displays the adjacency matrix.
-
process_math.Graph.Graph.sparse_matrix(self)¶ Fills the adjacency sparse matrix from the results of the modular multiplication for all vertices.
-
process_math.Graph.Graph.modulo_result(self, i)¶ Returns the result of the modular multiplication for a fixed vertex i.
- Parameters
i (int) – Vertex i
- Returns
Returns the result of the modular multiplication
- Return type
float
- Example
For N=2, i=7 and mod=10
>>> modulo_result(Graph(2,10),7) 4
-
process_math.Graph.Graph.print_graph(self)¶ Displays in a textual format all the vertices, each one of them is accompanied by all the edges incident to it.