22

I have a family tree from Cyril's amazing answer but I'm trying to figure out how to adjust it to support multiple partners. In this case, I added a "Mistress" node and am trying to denote that "Mistress" and "John" had a child named "Hidden Son".

The current data structure works like this:

enter image description here

In that, the root object stores everything. It has a children array which contains the up most "generation" with no parents. It also contains an object that contains the children of these sibling objects/nodes. In the example above, this is root.children[2].

I'm thinking I would have to refactor the data structure's children and inject information about whos parents the child is from. Just having trouble conceptualizing this, as well as the line

The end would would be something like this, except mistress would be on the left side:

enter image description here

Community
  • 1
  • 1
meder omuraliev
  • 171,706
  • 64
  • 370
  • 423
  • Hi @meder just wanted to let you know that i didn't receive the bounty you had set on this question...seems like its gone to the community :( – Cyril Cherian Dec 17 '15 at 05:32
  • @Cyril - how? I chose your answer?? – meder omuraliev Dec 17 '15 at 06:12
  • Yeah i am asking the same question to SO support http://meta.stackoverflow.com/questions/312522/i-didnt-get-the-bounty-for-a-question-i-answered/312544?noredirect=1#comment283829_312544 he says _Your answer is therefore ineligible for automatic awarding of the bounty and can only win the bounty if bounty owner take the explicit action of awarding it to you._ – Cyril Cherian Dec 17 '15 at 06:27
  • 1
    [Related meta discussion](http://meta.stackoverflow.com/q/312522/419956). – Jeroen Dec 17 '15 at 06:28
  • I think you need to unaccept and then accept the answer...I believe thats how it works – Cyril Cherian Dec 17 '15 at 06:43
  • Ok did that. Also made a newer bounty as well. – meder omuraliev Dec 17 '15 at 06:47
  • so need to wait for next 7 days..to find another SO bug LOL – Cyril Cherian Dec 17 '15 at 06:52
  • 1
    @meder http://meta.stackoverflow.com/questions/312522/i-didnt-get-the-bounty-for-a-question-i-answered?cb=1 – ketan Dec 17 '15 at 11:20
  • 3
    By the way, the way you award a bounty (you have to wait at least two days) is to click the box under the checkmark on the answer you've selected. Autoawarding only works if the answer was posted _during_ the bounty. Otherwise you must manually award by clicking the box under the checkmark. (Let me know when you've read this and I will be happy to clean up this comment.) – Kendra Dec 17 '15 at 15:33

1 Answers1

25

@medder thanks for the appreciation!

To do that I have added a hidden node between john and mistress.

And added a child to that hidden node, so it appears as if john and mistress have a child "Hidden Son" So the JSON looks like

{
    name: "Mistress",
    id: 9000,
    no_parent: true
  }, {
    name: "",//this is the new node between Mistress and John
    id: 100,
    no_parent: true,//it has no parents
    hidden: true,
    children: [{
      // so this hidden node will have a child 
      // which will make it appear as if john and mistress has a child.
      name: "Hidden Son",
      id: 9001
    }]
  }, {
    name: "John",
    id: 16,
    no_parent: true
  },

Working code here

Hope this helps!

Cyril Cherian
  • 30,992
  • 7
  • 41
  • 50