Graph
What is a graph ?
In programming, a graph is a common data structure that consists of a finite set of nodes (or vertices) and edges. The edges connect the vertices to form a network. An edge can be uni-directional or bi-directional. Edges are also known as arrows in a directed graph and may contain values that show the required cost to traverse from one vertex to another.
Types of graphs
1. Undirected graph :
In an undirected graph, an edge connects two nodes in both directions as a two-way street does.
2. Directed graph :
A directed graph only has directed edges. They can be imagined like a one-way street. If an edge leads from n1 to n2 it does not also lead from n2 to n1.