Skip to content

marfotop/Mathematical-Problems

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mathematical-Problems

In this repository there are programs that provide solution for mathematical problems, such as finding an Euler Circuit for a graph etc.

Eulerian Circuit Finder

A python code that creates an undirected graph with n nodes and edges between all pairs of distinct nodes, checks if the graph is Eulerian, and if so, finds an Eulerian circuit in the graph and prints it. If the graph is not Eulerian, it prints a message saying so. The code also includes commented out lines to display the graph.

Topological Sort

A python code that creates a directed acyclic graph with a fixed set of vertices and edges. It then attempts to generate a random topological sorting of the vertices in the graph using a loop that runs 3 times. If the graph contains no cycle, the sorted list of vertices is printed. If the graph contains a cycle, a message indicating this is printed. The random module is used to randomly shuffle vertices and break ties in the sorting process. Finally, the graph can be displayed using the commented out lines of code.

Inversion Sequence

A python code that defines a function find_inv(p) that computes the inversion sequence of a given list p. It then demonstrates the usage of this function on two example lists, p1 and p2, and prints the resulting inversion sequences.

Permutations

A python code that defines a function find_per(s) that computes a permutation of a given list s based on the Lehmer code. It then demonstrates the usage of this function on two example lists, s1 and s2, and prints the resulting permutations. If the resulting permutation starts with 0, it means there is no valid permutation for the given Lehmer code.

Rank

A python code that defines two functions find_inv and find_rank to calculate the inversion sequence and the rank of a given permutation, respectively. The find_inv function takes a list of integers that represents a permutation and returns the inversion sequence of that permutation as a list of integers. The find_rank function takes the inversion sequence of a permutation and calculates its rank. The code then uses these functions to calculate the inversion sequence and the rank of three example permutations and prints the results.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages