Hi Julia community
I have a question regrading the best data structure for a certain purpose.
I have a graph with of nodes i=1,…,n and edges and from the way I construct the graph I know all the maximum cliques c=1,…,k.
I am looking for a data structure that maps between vertices ans cliques that should have the following features:
- Quickly returning all the cliques that contain a node, given that node
- Quickly returning all nodes of a given clique,
- Quickly execute the following update to the data:
- For two neighbouring nodes, called parent_1 and parent_2, we dissect the edge by a new node (doesn’t yet affect the data structure but is important to understand the next step)
- For all cliques that contain both parents: delete that clique and replace it with two new cliques where the new node replaces parent_1 in the first new clique and parent_2 in the second one (all other nodes are as in the old, deleted clique).
The obvious choice for me would be a dataframes, where the rows are the nodes and the columns are the cliques and the entries are one/zero depending whether a node is/isn’t a member of a clique. However, I feel with the Dataframe I create a lot of unnecessary information since it stores a lot of zeros, as cliques are small compared to the whole graph. And I am not sure if tasks 1) and 2) become slows as the graph grows.
I have also played with two Dicts: A Vertex_to_Clique_Dict and a Clique_to_Vertex_Dict, which let me execute task 1) and 2) above quickly, but is very cumbersome when it comes to the update in 3), which is on the other hand easy when working with dataframes.
Is there a natural data structure that lends it self to my needs?
I am thankful for any suggestions.
Edit: Maximum Cliques instead of Maximal Cliques