GithubHelp home page GithubHelp logo

urastogi885 / find-euler-tour Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 1.0 746 KB

Find Euler tour, if it exists, for an undirected, connected, simple graph

Home Page: https://urastogi.me/projects/find-euler-tour/

License: MIT License

Python 32.62% C 67.38%
graph graphs graph-algorithms euler-tour undirected-graph undirected-graphs connected-graph simple-graph

find-euler-tour's Introduction

Find-Euler-Tour

Build Status License

Overview

The goal of this project is to find if an Euler tour exists for given undirected, connected, simple graphs, and to find such a tour, if they do indeed have one. The project has been developed to get the best asymptotic time complexity as well as the best constant factors, i.e., the usage of unnecessary operations were avoided. A final time complexity of Θ(|V||E|) was observed from reading the input till printing out an Euler tour, is it exists. Note that |V| and |E| represent total no. of vertices and edges in the given graph, G, respectively. The |V| factor in time complexity comes due to the Θ(|V|) time complexity of deletion since we have to search for the element to be deleted. Refer the UML activity diagram for further understanding of the code.


Figure 1 - An Euler Tour found for the above graph

The graph for the above Euler tour can be accessed from here.

Dependencies

  • The algorithm to find the euler tour has been implemented in C so only GCC is required to create executable.
  • The animation part of the project has been implemented in Python and has the following dependencies:
    • Opencv-python
    • Numpy
    • Networkx
    • Matplotlib

Input Format

  • The graph is stored in a adjacent list format. In each of the input graphs, vertices are numbered from 1 to |V|.
  • Each row includes a vertex, followed by zero or more other vertices. For example:
1 3 6
2 3 5
3 1 2 4 5
4 3 5
5 2 3 4 6
6 1 5
  • Notice that the vertices following the source vertex are in asecnding order.
  • The above sample input should be interpreted in the form of undirected edges as follows:
(1,3), (1,6)
(2,3), (2,5)
(3,4), (3,5)
(4,5)
(5,6)
  • Each row lists edges from a vertex of the graph.

Run

  • The following instructions are for Linux-based system. Use parallels for Windows.
  • Open the terminal, move into your workspace, clone the repository, and move into the project directory.
cd <your_worspace>/
git clone https://github.com/urastogi885/find-euler-tour.git
cd find-euler-tour/
  • Compile the source to create an executable
gcc euler_tour.c -std=c99 -o euler_tour
  • Run the executable while providing location of the input file
./euler_tour <input_file_location>
For instance:
./euler_tour input/in4.txt
  • Note that the location of the input file will be relative to your current directory
  • To get an animation of the Euler tour found, you can also run:
python3 animate_graph.py <input_file_location>
For instance:
python3 animate_graph.py input/in4.txt
  • Note that the above mentioned python script internally executes the c file for the same input.

Output Format

  • The total no. of operations and the time taken for execution are printed out on the terminal.
  • 2 files, A.txt and C.txt, are generated that contain an Euler tour, if it exists, and the total no. of operations respectively.
  • In A.txt, there are 2 lines. First line pertains to existence of an Euler tour in the given graph, denoted 1 or 0. Second line contains the Euler tour, if it exists. For example, if In2.txt is the given graph:
1
1 2 3 4 2 5 4 7 5 6 7 8 3 1 

find-euler-tour's People

Contributors

urastogi885 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

knut0815

find-euler-tour's Issues

Reduce time complexity

The current implementation takes Θ(|V||E|). I want to reduce it to Θ(|E|). The |V| factor comes due to Θ(|V|) time complexity of deletion. Take a look at the activity diagram and euler_tour.c.
Can we reduce the complexity of the overall implementation to Θ(|E|)?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.