# Category Archives: Graph

## Ways to Remove Edges from a Complete Graph to make Odd Edges

Given a complete graph with N vertices, the task is to count the number of ways to remove edges such that the resulting graph has… Read More »

## Print the lexicographically smallest DFS of the graph starting from 1

Given a connected graph with N vertices and M edges. The task is to print the lexicographically smallest DFS traversal of the graph starting from… Read More »

## Find the maximum value permutation of a graph

Given a graph containing N nodes. For any permutation of nodes P1, P2, P3, …, PN the value of the permutation is defined as the… Read More »

## Number of Hamiltonian cycle

Given an undirected complete graph of N vertices where N > 2. The task is to find the number of different Hamiltonian cycle of the… Read More »

## Minimum edges to be added in a directed graph so that any node can be reachable from a given node

Given a directed graph and a node X. The task is to find the minimum number of edges that must be added to the graph… Read More »

## Print the lexicographically smallest BFS of the graph starting from 1

Given a connected graph with N vertices and M edges. The task is to print the lexicographically smallest BFS traversal of the graph starting from… Read More »

## Count the number of nodes at a given level in a tree using DFS

Given an integer l and a tree represented as an undirected graph rooted at vertex 0. The task is to print the number of nodes… Read More »

## Minimum spanning tree cost of given Graphs

Given an undirected graph of V nodes (V > 2) named V1, V2, V3, …, Vn. Two nodes Vi and Vj are connected to each… Read More »

## Minimum number of edges between two vertices of a graph using DFS

Given an undirected graph G(V, E) with N vertices and M edges. We need to find the minimum number of edges between a given pair… Read More »

## Cost of painting n * m grid

Given two integers n and m which are the dimensions of a grid. The task is to find the cost of painting the grid cell… Read More »

## Number of Simple Graph with N Vertices and M Edges

Given two integers N and M, the task is to count the number of simple undirected graphs that can be drawn with N vertices and… Read More »

## Unique paths covering every non-obstacle block exactly once in a grid

Given a grid grid[][] with 4 types of blocks: 1 represents the starting block. There is exactly one starting block. 2 represents the ending block.… Read More »

## Clone an undirected graph with multiple connected components

Given an undirected graph with multiple connected components, the task is to clone the graph. Cloning a graph with a single connected component can be… Read More »

## Check if it is possible to reach a number by making jumps of two given length

Given a starting position ‘k’ and two jump sizes ‘d1’ and ‘d2’, our task is to find the minimum number of jumps needed to reach… Read More »

## Finding the path from one vertex to rest using BFS

Given an adjacency list representation of a directed graph, the task is to find the path from source to every other node in the graph… Read More »