Skip to content

Category Archives: Graph

Prerequisites – Graph, Spanning tree, Disjoint Set (Union – Find). A minimum spanning tree (MST) T, for a given graph G, spans over all vertices… Read More
Given an array arr[] consisting of N integers, the task is to find the minimum cost to sort the given array arr[] in ascending order… Read More
Given a 2D array, arr of size N*N where arr[i][j] denotes the cost to complete the jth job by the ith worker. Any worker can… Read More
Given an array arr[] of N pairs of strings representing a directed graph, where each pair of the strings represents an edge between the nodes… Read More
Given an undirected connected graph of N nodes and M edges. Each node has a light but at a time it can be either green… Read More
Given a directed and weighted graph of N nodes and M edges, the task is to find the 1st to Kth shortest path lengths from… Read More
Given a positive integer N denoting the number of astronauts(labelled from 0 from (N – 1))and a matrix mat[][] containing the pairs of astronauts that… Read More
Given a graph, G consisting of N nodes, a source S, and an array Edges[][2] of type {u, v} that denotes that there is an… Read More
The shortest path problem is the problem of finding a path between two vertices (or nodes) in a graph such that the sum of the… Read More
Given a weighted undirected graph G and an integer S, the task is to print the distances of the shortest paths and the count of… Read More
Given a directed graph G consisting of N nodes and N-1 edges, and a positive integer K, and initially, all the nodes of the graph… Read More
Given a complete graph having N nodes and N*(N-1)/2 edges and a positive integer K, the task is to find the number of ways if… Read More
Spanning tree: A spanning tree (T) of an undirected graph(G) is a subgraph which is a tree that includes all the vertices of a graph… Read More
A graph G is a collection of a set of vertices and a set of edges that connects those vertices. It consists of two sets:… Read More