Few important real life applications of graph data structures are:
Facebook: Each user is represented as a vertex(node) and two people are friends when there is an edge between two vertices. Similarly friend suggestion also uses graph theory concept.
Google Maps: Various locations are represented as vertices(nodes) and the roads are represented as edges and graph theory is used to find shortest path between two nodes.
Friends
Different Connections
Few important real life applications of graph data structures are:
Recommendations on e-commerce websites: The “Recommendations for you” section on various e-commerce websites uses graph theory to recommend items of similar type to user’s choice.
Graph theory is also used to study molecules in chemistry and physics.
graph | vertex | edge |
---|---|---|
financial stock | currency | transaction |
transportation | street intersection, airport | highway, airway route |
telephone | person | placed call |
One-way streets
graph | vertex | edge |
---|---|---|
communication | telephones, computers | fiber optic cables |
mechanical | joints | rods, beams, springs |
financia | stocks, currency | transactions |
Friend connections
using System.Collections.Generic;
public class Program
{
public static void Main()
{
Graph g = new Graph(new List<int>[] {
new List<int> {3, 6}, // successors of vertice 0
new List<int> {2, 3, 4, 5, 6},// successors of vertice 1
new List<int> {1, 4, 5}, // successors of vertice 2
new List<int> {0, 1, 5}, // successors of vertice 3
new List<int> {1, 2, 6}, // successors of vertice 4
new List<int> {1, 2, 3}, // successors of vertice 5
new List<int> {0, 1, 4} // successors of vertice 6
});
}
}
public class Graph
{
List<int>[] childNodes;
public Graph(List<int>[] nodes)
{
this.childNodes = nodes;
}
}