UPDATE
Some answers so far have suggested using an adjacency list. How would an adjacency list look like in Java? ... no pointers right :)
I'm trying to implement a Bipartite Graph in Java to sort into 2 groups information from a file. I found this example and it actually does the job:
http://users.skynet.be/alperthereal/source_files/html/java/Bipartite.java.html
However, I would like to implement my own version... if you look at a previous post of mine, you'd understand why I want to do this myself.
So I have to read a file from which I can get the number of vertices easily, but the number of edges not so easily. An example line would be "PersonA PersonB", which can be read as "PersonA says PersonB". So reading these lines...
"A says B"
"C says B"
"D says B"
"B says D"
"E says A & C"
... produces this grouping:
{A,D,C} and {B,E}.
How would I go about implementing this bipartite graph? What is a good resource for this task? What things (algorithms) should I be considering and thinking about when creating the BipartiteGraph class... perhaps traversing/sorting algorithms?