# Category Archives: Graph

## Find if there is a path between two vertices in a directed graph | Set 2

Given a Directed Graph and two vertices in it, check whether there is a path from the first given vertex to second. Example: Consider the… Read More »

## Print all possible paths in a DAG from vertex whose indegree is 0

Given a Directed Acyclic Graph (DAG), having N vertices and M edges, The task is to print all path starting from vertex whose in-degree is… Read More »

## Check if a graph is Strongly, Unilaterally or Weakly connected

Given an unweighted directed graph G as a path matrix, the task is to find out if the graph is Strongly Connected or Unilaterally Connected… Read More »

## Maximum cost path in an Undirected Graph such that no edge is visited twice in a row

Given an undirected graph having N vertices and M edges and each vertex is associated with a cost and a source vertex S is given.… Read More »

## Shortest path in a complement graph

Given an undirected non-weighted graph G. For a given node start return the shortest path that is the number of edges from start to all… Read More »

## Maximum number of bridges in a path of a given graph

Given an undirected graph, the task is to count the maximum number of Bridges between any two vertices of the given graph. Examples: Input: Graph… Read More »

## Count of prime factors of N to be added at each step to convert N to M

Given two integers N and M, the task is to find out minimum number of operations required to convert N to M. Each operation involves… Read More »

## Minimum nodes to be colored in a Graph such that every node has a colored neighbour

Given a graph G with V nodes and E edges, the task is to colour no more than floor(V/2) nodes such that every node has… Read More »

## Finding shortest path between any two nodes using Floyd Warshall Algorithm

Given a graph and two nodes u and v, the task is to print the shortest path between u and v using the Floyd Warshall… Read More »

## Proof that Clique Decision problem is NP-Complete | Set 2

Prerequisite: NP-Completeness, Clique problem. A clique in a graph is a set of vertices where each vertex shares an edge with every other vertex. Thus,… Read More »

## Count of all cycles without any inner cycle in a given Graph

Given an undirected graph consisting of N vertices numbered [0, N-1] and E edges, the task is to count the number of cycles such that… Read More »

## Isomorphism in N-ary Trees

Given two N-ary trees having M nodes each. Also, given their edges and their roots respectively. The task is to check if they are isomorphic… Read More »

## Sum of minimum element at each depth of a given non cyclic graph

Given a non-cyclic graph having V nodes and E edges and a source node S, the task is to calculate the sum of the minimum… Read More »

## Minimum Manhattan distance covered by visiting every coordinates from a source to a final vertex

Given an array arr[] of co-ordinate points and a source and final co-ordinate point, the task is to find the minimum manhattan distance covered from… Read More »

## Minimum clicks to convert string X to Y

Given a starting string X of 3 characters, finishing string Y of 3 characters and an array of forbidden strings. The task is to find… Read More »