Skip to content

Latest commit

 

History

History
68 lines (45 loc) · 2.39 KB

README.md

File metadata and controls

68 lines (45 loc) · 2.39 KB

Graph_based_Questions

This repository contains implementations of various graph algorithms and solutions to graph-based questions. Each file addresses a specific problem or algorithm related to graph theory, useful for both academic purposes and practical applications.

List of Files 1) BFS.java :- Implements the Breadth-First Search algorithm for graph traversal.

2) BellmanFord.java :- Solves the shortest path problem using the Bellman-Ford algorithm, which works even if the graph has negative weight edges.

3) CheapestFlight_KStops.java :- Finds the cheapest flight route with up to K stops between cities using a modified BFS algorithm.

4) ConnectCities.java :- Uses graph theory to determine the minimum cost to connect all cities.

5) DFS.java :- Implements the Depth-First Search algorithm for graph traversal.

6) DetectCycle.java :- Detects cycles in a graph using Depth-First Search.

7) Dijkstra_Algo.java :- Implements Dijkstra's algorithm for finding the shortest paths from a source node to all other nodes in a weighted graph.

8) Find_Union.java :- Implements the Union-Find data structure to manage a partition of a set into disjoint sets, useful for cycle detection in undirected graphs.

9) HasPath.java :- Determines if there is a path between two nodes in a graph.

10) Indegree.java :- Calculates the indegree of each node in a directed graph.

11) IsBiPartite.java :- Checks if a graph is bipartite using BFS or DFS.

12) Kruskals_Algo.java :- Implements Kruskal's algorithm for finding the Minimum Spanning Tree (MST) of a graph.

13) LargestSumCycle.java :- Finds the largest sum cycle in a weighted directed graph.

14) Prims_Algo.java :- Implements Prim's algorithm for finding the Minimum Spanning Tree (MST) of a graph.

15) PrintAllPath.java :- Prints all possible paths between two nodes in a graph.

16) Simple.java :- Solves a simple graph-based question (specifics to be detailed in the code).

17) Topological_Sort.java :- Implements topological sorting for a Directed Acyclic Graph (DAG).

18) isCycle_DFS.java :- Detects cycles in a graph using DFS.

Usage Each Java file can be compiled and run independently. To compile a file, use the following command in the terminal:

To run the compiled file, use:

javac filename.java

java filename

Replace with the name of the file you want to compile and run.