Topological Sorting In Graphs - Online Code


n graph theory, a topological sort or topological ordering of a directed acyclic graph (DAG) is a linear ordering of its nodes in which each node comes before all nodes to which it has outbound edges. Every DAG has one or more topological sorts. Topological sorting is sometimes also referred to as ancestral ordering (Neapolitan 2004).

Source Code

/* Program for topological sorting */


#define MAX 20

int n,adj[MAX][MAX];

int front=-1,rear=-1,queue[MAX];



	int i,j=0,k;

	int topsort[MAX],indeg[MAX];

... (login or register to view full code)

To view full code, you must Login or Register, its FREE.

Hey, registering yourself just takes less than a minute and opens up a whole new GetGyan experience.


No comment yet. Be the first to post a comment.