# Category Archives: Graph

## Erdos Renyl Model (for generating Random Graphs)September 3, 2017

In graph theory, the Erdos–Rényi model is either of two closely related models for generating random graphs. There are two closely related variants of the… Read More »

## Clustering Coefficient in Graph TheoryAugust 31, 2017

In graph theory, a clustering coefficient is a measure of the degree to which nodes in a graph tend to cluster together. Evidence suggests that… Read More »

## Print all paths from a given source to a destination using BFSAugust 12, 2017

Given a directed graph, a source vertex ‘src’ and a destination vertex ‘dst’, print all paths from given ‘src’ to ‘dst’. Consider the following directed… Read More »

## Calculate number of nodes between two vertices in an acyclic Graph by Disjoint Union methodJuly 29, 2017

Given a connected acyclic graph and a source vertex and a destination vertex, your task is to count the number of vertices between the given… Read More »

## 2-Satisfiability (2-SAT) ProblemJuly 19, 2017

Boolean Satisfiability Problem Boolean Satisfiability or simply SAT is the problem of determining if a Boolean formula is satisfiable or unsatisfiable. Satisfiable : If the… Read More »

## Clone a Directed Acyclic GraphJune 25, 2017

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 GraphJune 21, 2017

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 SearchJune 11, 2017

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 graphJune 6, 2017

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)June 5, 2017

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 rootJune 2, 2017

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 algorithmMay 17, 2017

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 constraintsMay 10, 2017

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 »