Project Breakdown - ross39/GraphTheoryProject GitHub Wiki
The breakdown of my project
How my project works
My project is broken into 3 files. I will explain each file in detail. The source code is also fully commented
shuntingYard.py
This file contains the code for the shunting yard algorithm. It was developed by Edsger Dijkstra. The purpose of the algorithm is to convert an infix expression into a postfix expression
A * B + C becomes A B * C +
The reason for this is that the expression becomes far easier to compute due to correctly formatting the order of precedence
Runner.py
This file is responsible for running the project. To start, simply use
Python3 Runner.py
I had to use python3 to specify I wanted python3 as I have two different versions of python on my machine.
operators.py
I called this file operators as it handles all the difficult operations. The initial part of the file contains two classes called state and nfa. State is used to set up and store the state of the nfa(Non-deterministic Finite Automaton). The class nfa is used to set up the nfa.
The def(function) called pofixNfa takes in a postfix string and creates small nfa's, and then combines them to create a large nfa that accepts the language. It uses a stack to push and pop the nfa's. In the end we're left with one big nfa which can be used to determine if we accept the string or not
A.B.C == ABC(Accept)