larch.model.tree.NestingTree.add_node

larch.model.tree.NestingTree.add_node

NestingTree.add_node(code, *, children=(), parent=None, parents=None, phi_parameters=None, **kwarg)[source]

Add a single node code and update node attributes.

Parameters
  • code (int) – Although the generic networkx.DiGraph allows a node to be any hashable Python object except None, Larch assumes that node codes are integers.

  • children (Collection) – A collection of other node codes that are the children of this new node. Links will be created from this node to each child.

  • parent (int, optional) – The parent of this new node. If not given, the root node is assumed to be the parent of this node, and an implied link is created. This implied link is removed if the node is later made the child of some other node. If the parent is set explicitly, the link is not removed later.

  • parents (Collection, optional) – Set multiple parent up-stream nodes.

  • phi_parameters (Mapping) – Set phi parameters on graph links connecting to this node, used in network GEV models. The keys of this mapping indicate the node at the other end of the link, and the values are parameter names.

  • kwarg (other keyword arguments, optional) – Set or change node attributes using key=value.