Android graphical implementation

I need to have a chart (or some equivalent data structure) in memory that needs to hold a set of IDS (numbers) and the requirement would be that the graph (or some data structure of some kind) can have around 10,000 nodes. explained below. Should I choose some API or my own custom implementation. Please think about memory and speed (please feel free to send me any suggestions.)

For example:

I would get all leaf nodes in every instance. those. In the picture below, I only need 6,7,8.

If the program removes 6 from the graph, the output will be 4,5,7,8

Sorry to stress again. Please think about memory and speed as it should work on Android.

thank

Graph Image

+3


source to share


2 answers


You can also look at the following post: Is there a Directed Acyclic Graph (DAG) datatype in Java and should I be using it?



What you want is a DAG (Directed Acyclig Graph) library.

+1


source


Which API implementation are you considering? I cannot think of any Java collection that suits your needs.

If you just implement your own, you can keep track of the leaves as the tree is created and modified, so when you need to get the leaves, you already have a list of them. If you are using a HashSet to keep track of leaves, I think you should be able to do all the tree operations without introducing unnecessary time complexity over the HashSet.



You will of course use the extra memory, but it is up to you to determine if this is a problem. I would say that even with 10k possible leaves and running on Android, this shouldn't be a concern.

0


source







All Articles