# Category Archives: Graph

## Minimum cost to connect weighted nodes represented as array

Given an array of N elements(nodes), where every element is weight of that node.Connecting two nodes will take a cost of product of their weights.You… 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 »

## Count single node isolated sub-graphs in a disconnected graph

A disconnected Graph with N vertices and K edges is given. The task is to find the count of singleton sub-graphs. A singleton graph is… Read More »

## DFS for a n-ary tree (acyclic graph) represented as adjacency list

A tree consisting of n nodes is given, we need to print its DFS. Examples : Input : Edges of graph 1 2 1 3… Read More »

## Maximum number of edges to be added to a tree so that it stays a Bipartite graph

A tree is always a Bipartite Graph as we can always break into two disjoint sets with alternate levels. In other words we always color… Read More »

## A Peterson Graph Problem

The following graph G is called a Petersen graph and its vertices have been numbered from 0 to 9. Some letters have also been assigned… 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 »

## Implementation of Graph in JavaScript

In this article we would be implementing the Graph data structure in JavaScript. Graph is a non-linear data structure. A graph G contains a set… Read More »

## Erdos Renyl Model (for generating Random Graphs)

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 Theory

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 BFS

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 method

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) Problem

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 »