# Category Archives: Graph

## Shortest path with exactly k edges in a directed and weighted graph | Set 2

Given a directed weighted graph and two vertices S and D in it, the task is to find the shortest path from S to D… Read More »

## Minimum Cost Graph

Given N nodes on a 2-D plane represented as (xi, yi). The nodes are said to be connected if the manhattan distance between them is… Read More »

## Count of different groups using Graph

Given a graph with N nodes having values either P or M. Also given K pairs of integers as (x, y) representing the edges in… Read More »

## Minimum cost to reach from the top-left to the bottom-right corner of a matrix

Given an N * M matrix mat[][] consisting of lower case characters, the task is to find the minimum cost to reach from the cell… Read More »

## Minimum cost to traverse from one index to another in the String

Given a string S of length N consisting of lower case character, the task is to find the minimum cost to reach from index i… Read More »

A graph is a presentation of a set of entities where some pairs of entities are linked by a connection. Interconnected entities are represented by… Read More »

## Find the minimum spanning tree with alternating colored edges

Given a graph with N nodes and M edges where each edge has a color (either black or green) and a cost associated with it.… Read More »

## Minimum cost to reverse edges such that there is path between every pair of nodes

Given a connected, directional graph. Each node is connected to exactly two other nodes. There is weight associated with each edge denoting the cost to… Read More »

## Check if given path between two nodes of a graph represents a shortest paths

Given an unweighted directed graph and Q queries consisting of sequences of traversal between two nodes of the graph, the task is to find out… Read More »

## Minimum number of edges that need to be added to form a triangle

Given an undirected graph with N vertices and N edges. No two edges connect the same pair of vertices. A triangle is a set of… Read More »

## Find count of pair of nodes at even distance

Given a connected acyclic graph with N nodes and N-1 edges, find out the pair of nodes that are at even distance from each other.… Read More »

## Print completed tasks at end according to Dependencies

Given N dependencies of the form X Y, where X & Y represents two different tasks. The dependency X Y denotes dependency of the form… Read More »

## Check if there exists a connected graph that satisfies the given conditions

Given two integers N and K. The task is to find a connected graph with N vertices such that there are exactly K pairs (i,… Read More »

## Welsh Powell Graph colouring Algorithm

In graph theory, vertex colouring is a way of labelling each individual vertex such that no two adjacent vertex have same colour. But we need… Read More »

## Word Ladder – Set 2 ( Bi-directional BFS )

Given a dictionary, and two words start and target (both of the same length). Find length of the smallest chain from start to target if… Read More »