Coder Social home page Coder Social logo

Attach a branch to a node about tree HOT 2 OPEN

nicmart avatar nicmart commented on June 3, 2024 1
Attach a branch to a node

from tree.

Comments (2)

localheinz avatar localheinz commented on June 3, 2024

@Ziggizag

Apologies for the delay! Can you clarify, please?

Can you please enhance your brilliant code implementing (pseudocode) as follows:

  1. $branch = $node->getBranch($childNode)

This should return an array defining $childNode (what is a child node of $node) with all its children.

I'm unsure what you mean by that, can you elaborate?

  1. What node does $node refer to?
  2. What node does $childNode refer to? Should it be a direct child of $node?
  3. What should the structure of $branch look like? A list of nodes? Which nodes?

from tree.

Ziggizag avatar Ziggizag commented on June 3, 2024

Hi,

The node is:

$node = new Node('foo');

$childNode is a direct child of a $node.

A $branch should be a structure keeping all information about a $childNode and all its children with their children and their children, etc. So, formally a $branch is a sub-tree.

The idea is to easily manipulate tree structure, like moving the entire branches (sub-trees) between nodes rather than re-creating them recursively.

from tree.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.