Lets say I have some data structure, it could be List[Map[String, List[String]]] or potentially Dataset[Map[String, List[String]]]
and it contains maps like the following
[a, (b)]
[b, (a, c, d)]
[c, (b, d)]
[d, (b, c)]
[e, (f, g)]
[f, (e)]
[g, (e, h)]
I would like to find a way to obtain the following
[a, (a, b, c, d)]
[b, (a, b, c, d)]
[c, (a, b, c, d)]
[d, (a, b, c, d)]
[e, (e, f, g, h)]
[f, (e, f, g, h)]
[g, (e, f, g, h)]
Is there a good way to code this up using spark? And what would be the best data types/structures to use for this process?
The only way I can think to solve this is to continuously loop over the maps and perform substitutions, but there must be a better way.