I need to have a Graph(or some equivalent data structure) in memory which should hold a set of IDS(numbers) and the requirement would be that the graph(or some datastructure) might have about 10000 nodes.The scenario is explained below. Should I choose any API or my own custom implementation.Please consider memory and speed (Please feel free to tell me any suggestions.)
Eg:
I would get all the leaf nodes at every instance. ie
In the figure below I would need only 6,7,8.
If the program removes 6 from the graph then the output would be 4,5,7,8
Sorry to stress it again.Please consider memory and speed as it should run on android.
Thanks

You might also want to have a look at the following post: Is there a Directed Acyclic Graph (DAG) data type in Java, and should I use it?
What you want is a DAG (Directed Acyclig Graph) library.