# Topic:graph

### Count the number of islands

Given a binary 2D matrix, containing the combination of 1's and 0's, where 0's represents the water and 1's represent the land. Our task is to find the count of the total number of connected islands. An island is...

### Count all possible paths between two vertices of a directed graph

Given a directed graph G, and two vertices: start s & end e, count all possible way of reaching the vertex e from vertex s. Note, these paths don't contain cycle as the existence of the cycle would lead...

### Minimum number of swaps required to sort a given array

Problem Statement: Given an array of n distinct elements, we have to find the minimum number of swaps required to sort the given array. Example - Input array - {2, 4, 5, 3, 1, 6} Output - 4 Explanation - Swap index 0...

### Detect Cycle in a Directed Graph

We are given a directed graph with V vertices and we have to find whether this directed graph contains a cycle or not. A cycle in a graph is a non-empty trail in which the first and last vertices are... 