| [ Web Proxy ] |
| Viewing: https://raw.githubusercontent.com/danogwok/Data-Structures-Algorithms/master/DisjointSet.java | [Back] [Original] |
// Java Program for union-find algorithm to detect cycle in a graph
import java.util.*;
import java.lang.*;
import java.io.*;
class Graph
{
int V, E; // V-> no. of vertices & E->no.of edges
Edge edge[]; // /collection of all edges
class Edge
{
int src, dest;
};
// Creates a graph with V vertices and E edges
Graph(int v,int e)
{
V = v;
E = e;
edge = new Edge[E];
for (int i=0; i
| Web Proxy Viewer | New URL | Original Page |