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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:16:19+00:00 2026-06-16T03:16:19+00:00

Hi I want to make a tree that keeps two-way references between parent and

  • 0

Hi I want to make a tree that keeps two-way references between parent and children. But it seems impossible to achive since when I create first object I do not have the other one yet therefore cannot have a reference to it. Here is some sample code.

-record(node,{name,children,root}).

main()->
    A = #node{name="node-A",
          children=[B], %variable B is  unbound
          root=nil},
    B = #node{name="node-B",
          children=[],
          root=A},
    Tree = A.

Another example to this problem would be implementing a doubly linked list (http://en.wikipedia.org/wiki/Doubly_linked_list)

-record(node,{prev,name,next}).

main()->
    A = #node{prev=nil,
          name="node-A",
          next=B}, % variable B is unbound
    B = #node{prev=A,
          name="node-B",
          next=nil},
    LinkedList = A.

Is there a way to implement this kind of structure.

  • 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-16T03:16:21+00:00Added an answer on June 16, 2026 at 3:16 am

    You can make doubly linked lists when you have “links” (like pointers). In erlang you don’t have such links and you don’t have even real variables, you can’t change them. Here are some examples for circular lists, but they should be implemented with caution: Can Circular Lists be defined in Erlang?

    Maybe you could tell us why you need doubly linked tree? Maybe there is a better solution in erlang.

    Edit: You could use digraph. Your tree can be represented as cyclic graph where you have vertices from A to B and from B to A. Example of a tree with root node A and children B and C:

    main()->
        Tree = digraph:new([cyclic]),
        A = digraph:add_vertex(Tree,"vertexA"),
        B = digraph:add_vertex(Tree,"vertexB"),
        C = digraph:add_vertex(Tree,"vertexC"),
        digraph:add_edge(Tree, A, B),
        digraph:add_edge(Tree, B, A),
        digraph:add_edge(Tree, A, C),
        digraph:add_edge(Tree, C, A),
        digraph:get_path(Tree, B, C).
    

    Result: ["vertexB","vertexA","vertexC"]

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

Sidebar

Related Questions

I want to make a function in standard ml that checks if a tree
I want to make my avl-tree support duplicate keys but there is a problem
so i want to make a code, that creates a binary tree, that holds
So i want to make a code, that creates a binary tree, that holds
I want to make a class in python, which would store a tree.Keeps taking
I want to make a simple phylogenetic tree for a marine biology course as
I want to make ^N work the same as Down arrow in a tree
I want to make characters in a game perform actions that are partially random
I am trying to make a data tree that holds multiple data types and
I want to make a tree where the same thing can be listed multiple

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.