I am currently writing my master's thesis. It's about graphs. My algorithm is ready. But now I have to think about useful data structures to represent the graph and the rest that I need for a good runtime. I am not allowed to use the adjacency matrix because of the large amount of memory. Since I have to check in every iteration whether a certain edge exists, adjacency lists also make no sense.
First I thought about two hash tables nested inside one another. All nodes are stored in the first table and all neighboring nodes in the second. But since I have to be able to choose a random neighbor in my algorithm, that is not optimal either. In addition, I have to be able to save edge weights in every iteration of the algorithm.
A list with all the basic operations:
- I need a presentation of the edges where I can check in O (1) if there is a certain edge exists
- I must be able to choose a random neighbor of a fixed node in O(1)
- I need to be able to assign weights to the edges in O (1)
- I also need to find out what the degree of a knot is in O (1)
I am allowed to use different data structures for all operations. Unfortunately, I'm running out of ideas.
I hope someone here can help me.
Thanks in advance!
Lisa