I am trying to vertex to 2 arraylist ( setA, setB) in which I am going to store vertices. Later on I am going to compare them using BFS and find the Maximam Size(Bipartite Graph) but i am stuck on getting the input.
here is what i have so far
import java.util.*;
public class BipartiteGraph {
private String strName;
ArrayList<Vertex>[] vertexList;
public BipartiteGraph(){
vertexList = new ArrayList[2];
vertexList[0] = new ArrayList<Vertex>();
vertexList[1] = new ArrayList<Vertex>();
}
public boolean setA(Vertex v1){
vertexList[0].add(v1);
return false;
}
public boolean setB(Vertex v2){
vertexList[1].add(v2);
return false;
}
}
class Vertex{
public String name;
public List adj;
public Vertex next;
public Vertex(String nm){
name = nm;
adj = new LinkedList();
}
}
class Edge{
public Vertex vertA;
public Vertex vertB;
public Edge( Vertex destination, Vertex comesfrom ){
vertA = comesfrom;
vertB = destination;
}
public static void main(String[] args){
Scanner vertexInput = new Scanner(System.in);
BipartiteGraph g = new BipartiteGraph( );
g.setA(vertexInput.nextBoolean()); <-- I get the error here and to resolve it I tried new Vertex(.....) but that did not work as well
}
}
How can i take the input correctly so that i can perform BFS search late. Also I need to use adjacency list. Can I use it with my current code later?