Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Solution for topological sort in cpp #2472 #1

Merged
merged 1 commit into from
Oct 28, 2023

Conversation

ranya17-bit
Copy link
Owner

Description
This Pull Request addresses issue DHEERAJHARODE#2472 by demonstrating Topological sorting, which is a linear ordering of vertices in a directed acyclic graph (DAG) in such a way that for every directed edge (u, v), vertex u comes before v in the ordering.

In this code,
The Graph class represents a directed graph using an adjacency list. The addEdge method is used to add directed edges to the graph. The topologicalSortUtil method is a helper function that performs a depth-first search (DFS) and pushes vertices onto a stack based on their topological order. The topologicalSort method initiates the topological sorting by calling topologicalSortUtil for each unvisited vertex.

Related Issue
Fixes DHEERAJHARODE#2472

Checklist
•I have tested the code and verified that it works as expected. •I have added comments and explanations for the code for better understanding. •The code follows the project's coding style and conventions. •The code has been formatted and does not contain any linting issues.

Description
This Pull Request addresses issue DHEERAJHARODE#2472 by demonstrating Topological sorting, which is a linear ordering of vertices in a directed acyclic graph (DAG) in such a way that for every directed edge (u, v), vertex u comes before v in the ordering.

In this code,
The Graph class represents a directed graph using an adjacency list.
The addEdge method is used to add directed edges to the graph.
The topologicalSortUtil method is a helper function that performs a depth-first search (DFS) and pushes vertices onto a stack based on their topological order.
The topologicalSort method initiates the topological sorting by calling topologicalSortUtil for each unvisited vertex.

Related Issue
Fixes DHEERAJHARODE#2472

Checklist
•I have tested the code and verified that it works as expected.
•I have added comments and explanations for the code for better understanding.
•The code follows the project's coding style and conventions.
•The code has been formatted and does not contain any linting issues.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant