## Magical Indices in an array

Given an array A of integers. Index i of A is said to be connected to index j if j = (i + A[i]) %… Read More »

## Mathematics | Graph Theory Basics – Set 1

A graph is a data structure that is defined by two components : A node or a vertex. An edge E or ordered pair is… Read More »

## Cycles of length n in an undirected and connected graph

Given an undirected and connected graph and a number n, count total number of cycles of length n in the graph. A cycle of length… Read More »

## Detecting negative cycle using Floyd Warshall

We are given a directed graph. We need compute whether the graph has negative cycle or not. A negative cycle is one in which the… Read More »

## Detect a negative cycle in a Graph | (Bellman Ford)

We are given a directed graph. We need compute whether the graph has negative cycle or not. A negative cycle is one in which the… Read More »

## Check if there is a cycle with odd weight sum in an undirected graph

Given a weighted and undirected graph, we need to find if a cycle exist in this graph such that the sum of weights of all… Read More »

## Check if a graphs has a cycle of odd length

Given a graph, the task is to find if it has a cycle of odd length or not. Recommended: Please try your approach on {IDE}… Read More »

## 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 »

## 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 »

## Find minimum weight cycle in an undirected graph

Given positive weighted undirected graph, find minimum weight cycle in it. Examples: Minimum weighted cycle is : Minimum weighed cycle : 7 + 1 +… Read More »

## Detect Cycle in a directed graph using colors

Given a directed graph, check whether the graph contains a cycle or not. Your function should return true if the given graph contains at least… Read More »

## Assign directions to edges so that the directed graph remains acyclic

Given a graph with both directed and undirected edges. It is given that the directed edges don’t form cycle. How to assign directions to undirected… Read More »

## Check if a given graph is tree or not

Write a function that returns true if a given undirected graph is tree and false otherwise. For example, the following graph is a tree. But… Read More »

## Euler Circuit in a Directed Graph

Eulerian Path is a path in graph that visits every edge exactly once. Eulerian Circuit is an Eulerian Path which starts and ends on the… Read More »

## Detect cycle in an undirected graph

. Given an undirected graph, how to check if there is a cycle in the graph? For example, the following graph has a cycle 1-0-2-1.… Read More »