Given an undirected graph of N nodes and M vertices. You are also given a K edges as selected[]. The task to maximize the shortest… Read More

# Category Archives: Graph

Given a source node S, a sink node T, two matrices Cap[ ][ ] and Cost[ ][ ] representing a graph, where Cap[i][j] is the… Read More

Given a graph consisting of N nodes numbered from 0 to N – 1 and M edges in the form of pairs {a, b}, the… Read More

Given a binary matrix mat[][], the task is to find the size of all possible non-empty connected cells. An empty cell is denoted by 0… Read More

Given a Directed Graph consisting of N vertices and M edges and a set of Edges[][], the task is to check whether the graph contains… Read More

Given an adjacency list representation of a Graph, the task is to convert the given Adjacency List to Adjacency Matrix representation. Examples: Input: adjList[] =… Read More

Given a graph of N Nodes and E edges in form of {U, V, W} such that there exists an edge between U and V… Read More

Prerequisites: Graph Theory Basics, Spanning tree. Complete Weighted Graph: A graph in which an edge connects each pair of graph vertices and each edge has… Read More

Given two integers V and E representing the number of vertices and edges of an undirected graph G(V, E), a list of edges EdgeList, and… Read More

Given an Undirected Graph consisting of N vertices and M edges, where node values are in the range [1, N], and vertices specified by the… Read More

Given an undirected graph of N nodes and M edges of the form {X, Y, Z} such that there is an edge between X and… Read More

Given a matrix board[][] consisting of the characters K or k, Q or q, B or b, N or n, R or r, and P… Read More

Given a Directed graph of N vertices and M edges, the task is to find the minimum number of edges required to make the given… Read More

Prerequisites: Graph and its representationsGiven an adjacency matrix g[][] of a graph consisting of N vertices, the task is to modify the matrix after insertion… Read More

Given an un-directed and unweighted connected graph, find a simple cycle in that graph (if it exists). Simple Cycle: A simple cycle is a cycle… Read More