# Graph Types and Applications

**Prerequisite:** Graph Theory Basics – Set 1, Graph Theory Basics – Set 2

A **graph** *G = (V, E)* consists of a set of vertices V = { V1, V2, . . . } and set of edges E = { E1, E2, . . . }. The set of unordered pairs of distinct vertices whose elements are called edges of graph G such that each edge is identified with an unordered pair (Vi, Vj) of vertices. The vertices (Vi, Vj) are said to be adjacent if there is an edge Ek which is associated to Vi and Vj. In such a case Vi and Vj are called end points and the edge Ek is said to be connect/joint of Vi and Vj.

**Types of Graph:**

**Finite Graphs:**A graph is said to be finite if it has finite number of vertices and finite number of edges.

**Infinite Graph:**A graph is said to be infinite if it has infinite number of vertices as well as infinite number of edges.**Trivial Graph:**A graph is said to be trivial if a finite graph contains only one vertex and no edge.**Simple Graph:**A simple graph is a graph which does not contains more than one edge between the pair of vertices. A simple railway tracks connecting different cities is an example of simple graph.**Multi Graph:**Any graph which contain some parallel edges but doesn’t contain any self-loop is called multi graph. For example A Road Map.**Parallel Edges:**If two vertices are connected with more than one edge then such edges are called parallel edges that is many routes but one destination.**Loop:**An edge of a graph which starts from a vertex and ends at the same vertex is called a loop or a self-loop.

**Null Graph:**A graph of order n and size zero is a graph where there are only isolated vertices with no edges connecting any pair of vertices.

**Order of a graph**: Number of vertices in a graph.**Size of a graph**: Number of edges in a graph.**Complete Graph:**A simple graph with n vertices is called a complete graph if the degree of each vertex is n-1, that is, one vertex is attached with n-1 edges or rest of the vertices in the graph. A complete graph is also called Full Graph.**Pseudo Graph:**A graph G with a self loop and some multiple edges is called pseudo graph.**Regular Graph:**A simple graph is said to be regular if all vertices of a graph G are of equal degree. All complete graphs are regular but vice versa is not possible.**Bipartite Graph:**A graph G = (V, E) is said to be bipartite graph if its vertex set V(G) can be partitioned into two non-empty disjoint subsets. V1(G) and V2(G) in such a way that each edge e of E(G) has its one end in V1(G) and other end in V2(G). The partition V1 U V2 = V is called Bipartite of G. Here in the figure: V1(G)={V5, V4, V3} and V2(G)={V1, V2}**Labelled Graph:**If the vertices and edges of a graph are labelled with name, data or weight then it is called labelled graph. It is also called*Weighted Graph*.

**Digraph Graph:**A graph G = (V, E) with a mapping f such that every edge maps onto some ordered pair of vertices (Vi, Vj) is called Digraph. It is also called*Directed Graph*. Ordered pair (Vi, Vj) means an edge between Vi and Vj with an arrow directed from Vi to Vj. Here in the figure: e1 = (V1, V2) e2 = (V2, V3) e4 = (V2, V4)**Subgraph:**A graph G1 = (V1, E1) is called subgraph of a graph G(V, E) if V1(G) is a subset of V(G) and E1(G) is a subset of E(G) such that each edge of G1 has same end vertices as in G.

**Types of Subgraph:****Vertex disjoint subgraph:**Any two graph G1 = (V1, E1) and G2 = (V2, E2) are said to be vertex disjoint of a graph G = (V, E) if V1(G1) intersection V2(G2) = null. In figure there is no common vertex between G1 and G2.**Edge disjoint subgraph:**A subgraph is said to be edge disjoint if E1(G1) intersection E2(G2) = null. In figure there is no common edge between G1 and G2.

Note:Edge disjoint subgraph may have vertices in common but vertex disjoint graph cannot have common edge, so vertex disjoint subgraph will always be an edge disjoint subgraph.

**Connected or Disconnected Graph:**A graph G is said to be connected if for any pair of vertices (Vi, Vj) of a graph G are reachable from one another. Or a graph is said to be connected if there exists at least one path between each and every pair of vertices in graph G, otherwise it is disconnected. A null graph with n vertices is disconnected graph consisting of n components. Each component consists of one vertex and no edge.**Cyclic Graph:**A graph G consisting of n vertices and n> = 3 that is V1, V2, V3- – – – – – – – Vn and edges (V1, V2), (V2, V3), (V3, V4)- – – – – – – – — -(Vn, V1) are called cyclic graph.

### Advantage:

- They are useful for implementing algorithms like DFS and BFS.
- Graph provides data accuracy.
- Graphs are useful for finding the shortest path.
- To find the minimum spanning tree.
- It is used in complex problems.
- It is useful for organizing data.

### Disadvantages:

- Graphs make data structures complex as they use pointers.
- A graph can have a large memory complexity.
- The graph is represented by an adjacency matrix that does not allow parallel edges.
- Multiplication in a graph is complex.

__Application of graphs:__

**Computer Science:**In computer science, graph is used to represent networks of communication, data organization, computational devices etc.**Physics and Chemistry:**Graph theory is also used to study molecules in chemistry and physics.**Social Science:**Graph theory is also widely used in sociology.**Mathematics:**In this, graphs are useful in geometry and certain parts of topology such as knot theory.**Biology:**Graph theory is useful in biology and conservation efforts.**Google map**also use graph. It is useful to find out which is an excellent place from the location as well as your nearby location. In GPS we also use graphs.**Facebook**uses graphs. Using graphs suggests mutual friends. it shows a list of the f following pages, friends, and contact list.**Microsoft Excel**we use*Directed Acyclic Graphs*.- In the
**Dijkstra algorithm,**we use a graph. - On
**social media**sites, we use graphs to track the data of the users. liked showing*suggestions*. - In
**computer science like**Dijkstra’s Algorithm, Prims’s Algorithm, Kruskal’s Algorithm

### Real-life application :

- Marketing on Social Media
- Algorithms for Search Engines
- Solving Sudoku Puzzles
- Directions On A Map
- Airline Scheduling.