Graph: A graph is a data structure that consists of the following two components: 1. A finite set of vertices also called as nodes. 2. A finite set of ordered pair of the form (u, v) called as edge. The pair is ordered because (u, v) is not the same as (v, u) in case of a directed graph(di-graph). The pair of the form (u, v) indicates that there is an edge from vertex u to vertex v. The edges may contain weight/value/cost. Graphs are used to represent many real-life applications: Graphs are used to represent networks. The networks may include paths in a city or telephone network or circuit network. Graphs are also used in social networks like linkedIn, Facebook. For example, in Facebook, each person is represented with a vertex(or node). Each node is a structure and contains information like person id, name, gender, and locale. Following is an example of an undirected graph with 5 vertices. The following two are the most commonly used representations of a graph. 1. Adjacen
Adjacency Matrix & Indegree Out degree & Adjacency List & BFS or DFS CODE 👇 #include<stdio.h> #include<stdlib.h> #define MAXSIZE 20 typedef struct node { int vertex; struct node * next; }NODE; NODE *list[10]; typedef struct { int front, rear; int info[MAXSIZE]; }QUEUE; void addq(QUEUE *pq, int n) { pq->info[++pq->rear] = n; } void initq(QUEUE *pq) { pq->front = pq->rear = -1; } int removeq(QUEUE *pq) { return pq->info[++pq->front]; } int isempty(QUEUE *pq) { return (pq->front == pq->rear); } void createmat(int m[10] [10], int n) { int i, j; //char ans; for(i=0; i<n; i++) for(j=0;j<n; j++) { m[i] [j] = 0; if(i != j) { printf("Is there an edge between %d->%d (1/0) :",i+1, j+1); scanf("%d", &m[i][j]); } } } void dismat( int m[10][10], int n) { int i, j;