# Category Archives: Graph

## Clone a Directed Acyclic Graph

A directed acyclic graph (DAG) is a graph which doesn’t contain a cycle and has directed edges. We are given a DAG, we need to… Read More »

## Minimum number of edges between two vertices of a Graph

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

## Count nodes within K-distance from all nodes in a set

Given an undirected tree with some marked nodes and a positive number K. We need to print the count of all such nodes which have… Read More »

## Bidirectional Search

Searching a graph is quite famous problem and have a lot of practical use. We have already discussed here how to search for a goal… Read More »

## Determine whether a universal sink exists in a directed graph

Determine whether a universal sink exists in a directed graph. A universal sink is a vertex which has no edge emanating from it, and all… Read More »

## Dynamic Connectivity | Set 1 (Incremental)

Dynamic connectivity is a data structure that dynamically maintains the information about thee connected components of graph. In simple words suppose there is a graph… Read More »

## Minimum edge reversals to make a root

Given a directed tree with V vertices and V-1 edges, we need to choose such a root (from given nodes from where we can reach… Read More »

## Karp’s minimum mean (or average) weight cycle algorithm

Given a directed and strongly connected graph with non negative edge weighs. We define mean weight of a cycle as the summation of all the… Read More »

## BFS for Disconnected Graph

In previous post, BFS only with a particular vertex is performed i.e. it is assumed that all vertices are reachable from the starting vertex. But… Read More »

## Move weighting scale alternate under given constraints

Given a weighting scale and an array of different positive weights where we have an infinite supply of each weight. Our task is to put… Read More »

## Minimum edges required to add to make Euler Circuit

Given a undirected graph of n nodes and m edges. The task is to find minimum edges required to make Euler Circuit in the given… Read More »

## Number of sink nodes in a graph

Given a Directed Acyclic Graph of n nodes (numbered from 1 to n) and m edges. The task is to find the number of sink… Read More »

## Best First Search (Informed Search)

Prerequisites : BFS, DFS In BFS and DFS, when we are at a node, we can consider any of the adjacent as next node. So… Read More »

## Top 10 Interview Questions on Depth First Search (DFS)

Depth-first search (DFS) is an algorithm for traversing or searching tree or graph data structures. One starts at the root (selecting some arbitrary node as… Read More »

## Largest subset of Graph vertices with edges of 2 or more colors

Given an undirected complete graph with N nodes or vertices. Edges of the graph are colored, find the largest subset of vertices with edges of… Read More »