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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:51:21+00:00 2026-05-28T01:51:21+00:00

I have a table Node with fields id and name, also I have a

  • 0

I have a table “Node” with fields “id” and “name”, also I have a table “Link” that links Node among themselves as many-to-many.

Node
id | name
1    node1
2    node2
3    node3
4    node4
5    node5
6    node4
7    node5

Link 
id | node_id | node2_id
1        1           2
2        2           3
3        3           5
4        2           4
5        3           6
6        3           7

         node4   node7
          |       |
node1-->node2-->node3-->node6
                  |
                 node5

How do I use python to generate this graph, list or dict with nested.
I have a problem with the construction of the algorithm. I have function get_derrived with returned a list of derived elements. My code is:

    c.tree = {}
    def get_tree(node_id):
        for node in get_derrived(node_id):
            if not node in c.tree:
                c.tree[node] = {}
                get_tree(node.id)           
    get_tree(id)

In sum I have for node1:

c.tree = {node1: {}, node2: {}, node3:{}, node4: {}, node5: {}, node6: {}, node7: {}}

for node2:

c.tree = {node2: {}, node4: {}, node3: {}, node5: {}, node6: {}, node7: {}}

But I need dict {node2: {node4: {}, node3: {node7: {}, node5: {}, node6: {} }}}.

  • 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-28T01:51:21+00:00Added an answer on May 28, 2026 at 1:51 am

    Please have look at this example from the python-graph.

    It shows how to programmatically create a grah and how to display it using graphviz (it should be already installed in your system if you’re using any Linux distribution).

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

Sidebar

Related Questions

I have a database that has node & nodetype tables. Nodes table NodeID ParentNodeID
I have table with some fields that the value will be 1 0. This
I have a table that contains my node data in a tree view. Each
I have table witch contains fields: id, parent_id, name (etc.) i want to order
I have a table which defines a child-parent relationship between nodes: CREATE TABLE node
I have table with 50 entries (users with such details like Name Surname Location
I have a drupal database where the node table is full of profiles. The
I have a table with fields category_id, category_name and parent_category_id. And parent_category_id has values
Let's say I have a categories table that stores categories. It is implemented in
I am trying to get this code to show only fields that have values,

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.