topological sort P6
#include <stdio.h> #include <stdlib.h> #define MAX_VERTICES 100 // Structure to represent a graph typedef struct { int V; int** adjMatrix; } Graph; // Function to create a new graph Graph* createGraph(int V) { Graph* graph = (Graph*)malloc(sizeof(Graph)); graph->V = V; graph->adjMatrix = (int**)calloc(V, sizeof(int*)); for (int i = 0; i < V; i++) { graph->adjMatrix[i] = (int*)calloc(V, sizeof(int)); } return graph; } // Function to add an edge to the graph void addEdge(Graph* graph, int src, int dest) { graph->adjMatrix[src][dest] = 1; } // Function to perform topological sorting void topologicalSort(Graph* graph) { int V = graph->V; int inDegree[MAX_VERTICES] = {0}; int queue[MAX_VERTICES], front = 0, rear = -1; // Calculate in-degree (number o...