# Category Archives: Graph

## Reverse Delete Algorithm for Minimum Spanning Tree

Reverse Delete algorithm is closely related to Kruskal’s algorithm. In Kruskal’s algorithm what we do is : Sort edges by increasing order of their weights.… Read More »

## Check if removing a given edge disconnects a graph

Given an undirected graph and an edge, the task is to find if the given edge is a bridge in graph, i.e., removing the edge… Read More »

## Boggle | Set 2 (Using Trie)

Given a dictionary, a method to do a lookup in the dictionary and a M x N board where every cell has one character. Find… Read More »

## Total number of Spanning Trees in a Graph

If a graph is a complete graph with n vertices, then total number of spanning trees is n(n-2) where n is the number of nodes… Read More »

## Chinese Postman or Route Inspection | Set 1 (introduction)

Chinese Postman Problem is a variation of Eulerian circuit problem for undirected graphs. An Euler Circuit is a closed walk that covers every edge once… Read More »

## Hierholzer’s Algorithm for directed graph

Given a directed Eulerian graph, print an Euler circuit. Euler circuit is a path that traverses every edge of a graph, and the path ends… Read More »

## Graph implementation using STL for competitive programming | Set 2 (Weighted graph)

In Set 1, unweighted graph is discussed. In this post, weighted graph representation using STL is discussed. The implementation is for adjacency list representation of… Read More »

## Graph implementation using STL for competitive programming | Set 1 (DFS of Unweighted and Undirected)

We have introduced Graph basics in Graph and its representations. In this post, a different STL based representation is used that can be helpful to… Read More »

## k’th heaviest adjacent node in a graph where each vertex has weight

Given a positive number k and an undirected graph of N nodes, numbered from 0 to N-1, each having a weight associated with it. Note… Read More »

## Check loop in array according to given constraints

Given an array arr[0..n-1] of positive and negative numbers we need to find if there is a cycle in array with given rules of movements.… Read More »

## Two Clique Problem (Check if Graph can be divided in two Cliques)

A Clique is a subgraph of graph such that all vertcies in subgraph are completely connected with each other. Given a Graph, find if it… Read More »

## Minimum Product Spanning Tree

Given a connected and undirected graph, a spanning tree of that graph is a subgraph that is a tree and connects all the vertices together.… Read More »

## Minimum Cost Path with Left, Right, Bottom and Up moves allowed

Given a two dimensional grid, each cell of which contains integer cost which represents a cost to traverse through that cell, we need to find… Read More »

## Find if an array of strings can be chained to form a circle | Set 2

Given an array of strings, find if the given strings can be chained to form a circle. A string X can be put before another… Read More »

## Minimum number of swaps required to sort an array

Given an array of n distinct elements, find the minimum number of swaps required to sort the array. Examples: Input : {4, 3, 2, 1}… Read More »