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 8048989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:39:19+00:00 2026-06-05T06:39:19+00:00

I am having trouble getting my head around how to approach this… I am

  • 0

I am having trouble getting my head around how to approach this… I am not asking for an explicit answer, just a heads up about what approach to take. As I have run into problems with every one I have taken so far.

I have a set of nodes:

nodes = { ('A','B'),
          ('B','C'),
          ('C','D'),
          ('C','E'),
          ('B','E'),
          ('C','F')}

as a dictionary of sets:

nodedict = { 'A': {'B'},
             'C': {'B', 'E', 'D', 'F'},
             'B': {'A', 'C', 'E'},
             'E': {'C', 'B'},
             'D': {'C'},
             'F': {'C'} }

what I want to do is to build a structure like this:

for ‘A’

                               A
                               |
                               B
                      _________|_________
                      |                  |
                      C                  E
                 _____|_____             |
                 |    |     |            C
                 D    E     F        ____|____
                                     |        |
                                     D        F

so all possible routes from A can be found.

I have been using a list to represent the braches, and then trying to wrap a for loop in a while loop… appending each list with its children if the child is not in the list… but I keep coming unstuck. I sometimes get close, but this is when I am writing explicit for loops and know exactly what I am looking for.

is it best to try to get to one tip first, then backtrack and then to the next tip …

for x in xs:
   ...
   for a in x:
      ...
      for b in a

but obviously I do not know how deep node ‘n’ goes… hmmm… any helpful suggestions 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-06-05T06:39:21+00:00Added an answer on June 5, 2026 at 6:39 am

    I have no experience with python, however you have said you do not want an explicit answer.

    You have a tree. This is one of the most well covered structures out there and there are many ways to represent it and traverse it.

    At minimum you need to know the node at the root of the tree and be able to retrieve the children of any given node. From those two pieces of information it is possible to traverse the entire tree if you keep track of what you’re doing.

    Look into Tree traversal.

    There is also a question on implementing a tree in python here.

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

Sidebar

Related Questions

I am having trouble getting my head around this query for some reason and
I'm having real trouble getting my head around this issue. As the title suggests,
I'm having some trouble getting my head around how best to solve this situation
I'm having a little of trouble getting my head around this - maybe because
This issue is so deceptively simple that I'm having trouble getting my head around
I'm having trouble getting my head around algorithm analysis. I seem to be okay
For some reason I am having trouble getting my head around __init__ and __new__
I'm having some trouble getting my head around the jquery queue method. I've got
I'm having a little trouble getting my head around a Javascript animated scroll issue.
I'm having trouble getting my head around RecrusiveIteratorIterator and relatives to iterate over an

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.