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

  • Home
  • SEARCH
  • 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 6570827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:48:18+00:00 2026-05-25T14:48:18+00:00

My source structure is either a Dictionary looking like: new Dictionary<string, string>(); dic.Add(Dinges, new

  • 0

My source structure is either a Dictionary looking like:

new Dictionary<string, string>();
dic.Add("Dinges", new List<String>() { "A", "B" });
dic.Add("Facebook", new List<String>() { "Dinges" });
dic.Add("SocialMedia", new List<String>() { "FaceBook" });
dic.Add("Medium", new List<String>() { "SocialMedia" })

Or a list of tuples looking like:

new List<Tuple<String, String>>();
list.Add(Tuple.Create("Dinges", "A");
list.Add(Tuple.Create("Dinges", "B");
list.Add(Tuple.Create("Facebook", "Dinges"); 
list.Add(Tuple.Create("SocialMedia", "Facebook");
list.Add(Tuple.Create("Medium", "SocialMedia");

These are associations between items, maybe best described as an inheritance tree. Medium being the most general class, A the most specialized.

What I’m looking for is a way to rearrange the items to look like the following:

new List<Tuple<String, String>>();
list.Add(Tuple.Create("Dinges", "A");
list.Add(Tuple.Create("Dinges", "B");
list.Add(Tuple.Create("Facebook", "Dinges"); 
list.Add(Tuple.Create("Facebook", "A");
list.Add(Tuple.Create("Facebook", "B");
list.Add(Tuple.Create("SocialMedia", "A");
list.Add(Tuple.Create("SocialMedia", "B");
list.Add(Tuple.Create("SocialMedia", "Dinges");
list.Add(Tuple.Create("SocialMedia", "Facebook");
list.Add(Tuple.Create("Medium", "A");
list.Add(Tuple.Create("Medium", "B");
list.Add(Tuple.Create("Medium", "Dinges");
list.Add(Tuple.Create("Medium", "FaceBook");
list.Add(Tuple.Create("Medium", "SocialMedia");

I really need some help accomplishing this, I’ve had some tips in the way of a transitive closure, but I really can;t wrap my head around it. Any help would be really much 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-25T14:48:19+00:00Added an answer on May 25, 2026 at 2:48 pm

    From the dictionary approach, which I assume was meant to be declared as a Dictionary<string, List<string>>:

    private static IEnumerable<string> TransitiveValues(string name,
                        Dictionary<string, List<string>> lookup)
    {
        yield return name;
        List<string> children;
        if (lookup.TryGetValue(name, out children))
        {
            foreach (string child in children)
            {
                foreach (string value in TransitiveValues(child, lookup))
                {
                    yield return value;
                }
            }
        }
    }
    

    Then:

    var query = from name in dictionary.Keys
                from value in TransitiveValues(name, dictionary)
                select Tuple.Create(name, value);
    var list = query.ToList();
    

    Just make sure you don’t have any cycles 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given a pretty basic source tree structure like the following: trunk ------- QA |--------
I have been working on standardizing the source control structure for our Team Foundation
Disclaimer: I'm stuck on TFS and I hate it. My source control structure looks
The directory structure of my Silverlight project is like the following: \Bin - MainModule.xap
I have a Util package with source files in three seperate directories, defined like
I'm a lone developer who would like to get some structure to my projects.
Source RegexOptions.IgnoreCase is more expensive than I would have thought (eg, should be barely
Source: <TD> <A HREF=/home><IMG SRC=/images/home.gif></A> <IMG SRC=/images/spacer.gif> <A HREF=/search><IMG SRC=/images/search.gif></A> <IMG SRC=/images/spacer.gif> <A HREF=/help><IMG
My source code needs to support both .NET version 1.1 and 2.0 ... how
Can source code examples be kept in a SQL database while retaining all formatting

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.