I hope this description will suffice, the best way to put it in words is just giving an example of what it is now and how I want it to be. Here goes.
When I execute a certain method, a structure will be generated. Which may have the following content:
> Key: FaceBook, Value: Dinges
> Key: SocialMedia, Value: FaceBook
> Key: Medium, Value: SocialMedia
These are associations. According to this Dinges is associated with FaceBook, Facebook is associated with SocialMedia and SocialMedia is associated with Medium.
Now, what I actually need is the following layout:
> Key: FaceBook, Value: Dinges
> Key: SocialMedia, Value: FaceBook
> Key: SocialMedia, Value: Dinges
> Key: Medium, Value: SocialMedia
> Key: Medium, Value: Facebook
> Key: Medium, Value: Dinges
I actually have no idea how to approach this. Any help would be greatly appreciated
So, basically, you want to create the transitive closure of your source dictionary. If you don’t have any loops in your dictionary, a simple algorithm creating a new
List<Tuple<string, string>>could look like this:EDIT2: Since it’s quite easy to translate in C#, here you are: