data structures using printf("\ enter the adjacency matrix")for( maxi++for( maxj++scanf("% "&adj[ ][ ])printf("dfs traversal")depth_first_search(adj,visited, )printf("\ ")return output enter the adjacency matrix dfs traversala - - - topological sorting topological sort of directed acyclic graph (dagg is defined as 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 number of topological sorts topological sort of dag is an ordering of the vertices of such that if contains an edge (uv)then appears before in the ordering note that topological sort is possible only on directed acyclic graphs that do not have any example consider three dags shown in fig cycles for dag that contains cyclesno and their possible topological sorts linear ordering of its vertices is possible in simple wordsa topological ordering of dag is an ordering of its vertices such that any directed path in traverses the vertices in increasing order topological sorting is widely used in scheduling applicationsjobsor tasks the jobs that have to be completed are represented by nodesand there is an edge from node to if job must be completed before job can be started topological sort topological sort topological sort topological sort can be given ascan be given ascan be given asof such graph gives an order in which the abcde abdcef abcfdec given jobs must be performed abced acbde acbed figure abdcfe abcdef abcdfe abfed abcdefg abcdfeg abdcefg abdcfeg topological sort one main property of dag is that more the number of edges in dagfewer the number of topological orders it has this is because each edge (uvforces node to occur before vwhich restricts the number of valid permutations of the nodes algorithm the algorithm for the topological sort of graph (fig that has no cycles focuses on selecting node with zero in-degreethat isa node that has no predecessor the two main steps involved in the topological sort algorithm includeselecting node with zero in-degree deleting from the graph along with its edges