diff --git a/VertexCover.java b/VertexCover.java new file mode 100644 index 0000000..8f9a44d --- /dev/null +++ b/VertexCover.java @@ -0,0 +1,89 @@ +// Java Program to print Vertex Cover of a given undirected graph +import java.io.*; +import java.util.*; +import java.util.LinkedList; + +// This class represents an undirected graph using adjacency list +class Graph +{ + private int V; // No. of vertices + + // Array of lists for Adjacency List Representation + private LinkedList adj[]; + + // Constructor + Graph(int v) + { + V = v; + adj = new LinkedList[v]; + for (int i=0; i i; + + // Consider all edges one by one + for (int u=0; u