Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6589455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:10:39+00:00 2026-05-25T17:10:39+00:00

I hope this description will suffice, the best way to put it in words

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T17:10:40+00:00Added an answer on May 25, 2026 at 5:10 pm

    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:

    for each pair (key, value) in your dictionary:
        do
            list.add(key, value)
            if value is not a key in the dictionary, break loop
            value = dictionary(value)
        loop
    

    EDIT2: Since it’s quite easy to translate in C#, here you are:

    Dictionary<string, string> dic = new Dictionary<string, string>(); // base data
    dic.Add("FaceBook", "Dingens");
    dic.Add("SocialMedia", "FaceBook");
    dic.Add("Medium", "SocialMedia");
    
    var list = new List<Tuple<string, string>>();  // result
    
    foreach (var de in dic)
    {
        var value = de.Value;
        do
        {
            list.Add(Tuple.Create(de.Key, value));
        } while (dic.TryGetValue(value, out value));
    }
    
    foreach (var x in list)
        Console.WriteLine(x.Item1 + ": " + x.Item2);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hope this will be a quick easy question, I've just tried my app on
(I hope this is a right description for what I want to achieve -
Hope this makes sense... Is there a simple way to return a set of
Here is a description of what I want to do in a Swing application.
I have a model Product with a description field. Now I want to have
Let's say I have a table like this (this is just a simplified example,
I hope somewhere out there will be able to help me on this. I
Hello This is a complex question and I hope someone will be so nice
Hope this question is not stupid since I am an amateur web designer. I
Hope this is the right place to be asking this, so my apologies if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.