Skip to content

Category Archives: Graph

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
Given a binary matrix mat[][] of dimensions N*M, the task is to find the minimum number of flips required from the given binary matrix such… Read More
Given a matrix of dimensions N*M consisting of characters ‘M’, ‘#’, ‘.’ and only a single instance of ‘A’. The task is to print any… Read More
Independent set of Graph as a pre-requisite is the set of vertices where no two are adjacent to each other. It is just opposite in… Read More
Given an unweighted and undirected graph consisting of N nodes and two integers a and b. The edge between any two nodes exists only if… Read More