DEV Community

Jidneya
Jidneya

Posted on • Edited on

Math's in computer science: Graph theory

Graph theory is a pretty big deal in computer science, and often regarded as a topic that just focuses on computer science. However graph theory is so much bigger than just computer science, it is more accurate to say that it is the study of the field of graphs, whose applications in computer science are invaluable to say the least. I hope to enlighten you with this knowledge.

Firstly I think it is important to explain what we mean by a graph in this context. A graph is something that we use to help define and visualize relationships between components. We do this visually by calling the components "nodes", and the lines that connect them to other components as "edges". An example is below (credit to GeeksforGeeks for the picture)

Image description

Now it is time to discuss the types of graphs:

  • Weighted graph: This is a graph where the edges represent a value, such as maybe the distance from points, or the time is takes to go from point to point.

  • Undirected Graph: A graph where the edges don't point from one node to another, so it is bidirectional relationship.

  • Directed Graph: A graph where the edges do point from one node to another to symbolize a one way relationship.

  • Trees: Trees are undirected graphs where two nodes are only ever connected by one edge.

But why would we take the time and effort to learn this topic that just seems like a bunch of circles connected by lines. One direct application is GPS. You can model the streets as graphs and this proves to be very useful. Other applications include social networks, computer networks, and even when computers solve sudoku puzzles.

Great now you know the basics of Graph theory. The topic goes so much deeper so i will need more than one post to delve into this. I hoped you enjoyed reading.

Top comments (0)