What are Graphs? What are they used for? - How it Works Types of Graphs

What are Graphs?


In computer science, the term "Graph" refers to a way programmers represent relationships between different datapoints or objects. The datapoints / objects in a graph are known as "Vectices" and the relationships between them are known as "Edges". Vectices and edges connect together to form a network like structure known as a "Graph" and they're generally visualized by the diagram below.


What are Graphs used for?


Programmers use Graphs to help visualize and represent the relationship between data objects in their code, similar to how a mathematician may use graphs to illustrate the trends in a dataset.

Fig 1. line graph
Fig 2. directed graph in computer science

In addition to visualization, graphs can also help programmers model and solve a variety of coding problems.


Types of Graphs


There are 2 types of graphs:

Undirected

A "Undirected Graph" is a graph where the edges have no direction, indicating a two way relationship between 2 vertices. A graph representing the friend list of a user on a social media site might contain this type of relationship.


Directed

A "Directed Graph" is a graph where the edges have direction, indicating a one way / two way relationship between 2 vertices. And sometimes edges of a directed graph are "weighted", meaning they'll have some value associated with them


Mixed

A "Mixed Graph" is a graph where the edges have some direction and some no direction. For example, a map with traffic directions. Some streets are 'oneways' while others are 'twoways'



Graph Traversal