Java Program to Find the Longest Path in a Directed Acyclic Graph

This is a java program to find longest path in DAG. Here is the source code of the Java Program to Find the Longest Path in a DAG. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.  package com.sanfoundry.hardgraph; import java.util.Scanner;import java.util.Vector; class Node{ int name; // … Read more

advertisement

Java Program to Find the Minimum Number of Edges to Remove to Disconnect a Graph

This is a java program to find bridges in a graph. Here is the source code of the Java Program to Find Minimum Number of Edges to Cut to make the Graph Disconnected. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.  package com.sanfoundry.hardgraph; import java.util.Iterator;import … Read more

advertisement

Java Program to Check if Graph is DAG

This is a java program to check whether graph is DAG. In mathematics and computer science, a directed acyclic graph (DAG Listeni/’dæg/), is a directed graph with no directed cycles. That is, it is formed by a collection of vertices and directed edges, each edge connecting one vertex to another, such that there is no … Read more

advertisement

Java Program to Remove the Edges in a Cyclic Graph such that its Linear Extension can be Found

This is a java program to set of edges upon removal of which linear extension can be found. In simple terms this version of code finds the feedbackarc set, which when removed from graph leads to DAG for which we can find the topological sorting. Here is the source code of the Java Program to … Read more

advertisement

Java Program to Check if a Directed Graph is Weakly Connected or Not using DFS

This is a java program to test whether a directed graph is weakly connected or not. The graph is weakly connected if it has more than one connected component. Here is the source code of the Java Program to Test Using DFS Whether a Directed Graph is Weakly Connected or Not. The Java program is … Read more

advertisement

Java Program to Check if a Graph is a Tree or Not using DFS

This is a java program to check if graph is tree or not. Graph is tree if, 1. It has number of edges one less than number of vertices. 2. Graph is connected. 3. There are no cycles. Here is the source code of the Java Program to Check if a Directed Graph is a … Read more

advertisement

Java Program to Find the Connected Components in an UnDirected Graph

This is a java program In graph theory, a connected component (or just component) of an undirected graph is a subgraph in which any two vertices are connected to each other by paths, and which is connected to no additional vertices in the supergraph. A graph that is itself connected has exactly one connected component, … Read more

advertisement

Java Program to Create a Minimal Set of All Edges Whose Addition will Convert it to a Strongly Connected DAG

This is a java program to find the edges other than feedback arc set so that all the edges contribute to directed acyclic graph. Here is the source code of the Java Program to Create a Minimal Set of All Edges Whose Addition will Convert it to a Strongly Connected DAG. The Java program is … Read more

advertisement

Java Program to Apply DFS to Perform the Topological Sorting of a Directed Acyclic Graph

This is a java program to find topological sort of DAG. In computer science, a topological sort (sometimes abbreviated topsort or toposort) or topological ordering of a directed graph is a linear ordering of its vertices such that for every directed edge uv from vertex u to vertex v, u comes before v in the … Read more

advertisement

Java Program to Check Whether Topological Sorting can be Performed in a Graph

This is a java program to check if topological sorting can be performed on graph or not. Topological sort exists only if there is not cycle in directed graph. In short this problem can be reduced to check if the given graph is Directed Acyclic Graph. If it is topological sort can be performed, not … Read more

advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.