Sunday, August 16, 2020

Graph Representations & Graph Traversals

Graphs have two primary components known as i) vertex and ii) a pair of Vertex bonding to form an edge.

Graphs can be represented in two different ways.
  1. Adjacency Matrix : The Distance between two vertices are represented in a row X column format.
  2. Adjacency List: An Array of linked Lists are maintained representing each node and its respective edges with other nodes.

The method to traverse a Graph is as follows: 
  1. Breadth First Traversal/Search
  2. Depth First Traversal/Search

Breadth First Traversal(BFS):


Breadth First Traversal is used to traverse all the nodes in a graph, and the order of it is determined using a Queue structure.


Depth First Traversal(DFS):


Depth First Traversal uses a a stack/recursive method approach to traverse all the nodes in a graph.

DFS can be implemented using a recursive method.
This post was originally drafted on 13th Feb 2018.

Django & Connecting it to MySQL

Connection to MySQL Database was a bit challenging task for me.


Background:

I started my Django experience with connection to the default database which is extremely light weight i.e. SQLite. This database gets locked at connecting to it more than once.

In my situation, the db got locked when I was trying to access it from a DB browser while having the Django server running. 

To make things more dynamic and to learn MySQL I began mulling on the idea to setup it up along with Django. 

Now back to the problem.
You primarily have to deal with setting.py under your base directory (BASE_DIR). 

In settings.py file of the Django Project, replace the sqlite3 engine with mysql engine as shown below.



Below given is the reference to mysql engine.


[Note: If you are migrating to MySQL after building the project with any other database, ensure that the migration folder under the apps are deleted.]

References are mentioned below. 

[Originally drafted on 6th August 2018]