Adds a new node as a sibling to the current node object.
330362
def add_sibling(self, pos=None, **kwargs):
        """"""
        pos = self._prepare_pos_var_for_add_sibling(pos)

        if len(kwargs) == 1 and 'instance' in kwargs:
            # adding the passed (unsaved) instance to the tree
            newobj = kwargs['instance']
            if newobj.pk:
                raise NodeAlreadySaved("Attempted to add a tree node that is "\
                    "already in the database")
        else:
            # creating a new object
            newobj = get_result_class(self.__class__)(**kwargs)

        if not self.node_order_by:
            newobj.sib_order = self.__class__._get_new_sibling_order(pos,
                                                                     self)
        newobj.parent_id = self.parent_id
        newobj.save()
        return newobj
988701
def _append_node(self, child):
        """"""
        # pylint: disable=no-member; depending by the class
        # which uses the current class as a mixin or base class.
        # It's rewritten in 2.0, so it makes no sense for now
        # to spend development time on it.
        self.body.append(child)
        child.parent = self
776349
def add_node(self, name_base, attrs=None):
        """"""
        if name_base not in self.counters:
            node_id = name_base
        else:
            node_id = '%s_%d' % (name_base, self.counters[name_base])
        node = {'id': node_id}
        if attrs:
            node['attrs'] = attrs
        self.nodes.append(node)
        self.counters[node_id] += 1
        return node_id
885600
public void add(N node) {
        if (! node.added) {
            nodes.add(node);
            node.added = true;
        }
    }
56177
def add_node_to_network(self, node, network):
        """"""
        network.add_node(node)
        parents = node.neighbors(direction="from")
        if len(parents):
            parent = parents[0]
            parent.transmit()
        node.receive()
1306275
def add_root(cls, **kwargs):
        """"""

        # do we have a root node already?
        last_root = cls.get_last_root_node()

        if last_root and last_root.node_order_by:
            # there are root nodes and node_order_by has been set
            # delegate sorted insertion to add_sibling
            return last_root.add_sibling('sorted-sibling', **kwargs)

        if last_root:
            # adding the new root node as the last one
            newtree_id = last_root.tree_id + 1
        else:
            # adding the first root node
            newtree_id = 1

        if len(kwargs) == 1 and 'instance' in kwargs:
            # adding the passed (unsaved) instance to the tree
            newobj = kwargs['instance']
            if newobj.pk:
                raise NodeAlreadySaved("Attempted to add a tree node that is "\
                    "already in the database")
        else:
            # creating the new object
            newobj = get_result_class(cls)(**kwargs)

        newobj.depth = 1
        newobj.tree_id = newtree_id
        newobj.lft = 1
        newobj.rgt = 2
        # saving the instance before returning it
        newobj.save()
        return newobj
107854
def add_nodes(self, new_nodes):
        """"""
        for unique_id, node in new_nodes.items():
            if unique_id in self.nodes:
                raise_duplicate_resource_name(node, self.nodes[unique_id])
            self.nodes[unique_id] = node
996172
def add_node(self, node):
        """"""
        for predecessor in self._most_recent_predecessors_to(node):
            predecessor.connect(whom=node)
558333
def add_node(node)
      raise Abuelo::Exceptions::NodeAlreadyExistsError if has_node?(node)

      @nodes[node.name] = node
      node.graph = self

      self
    end
626963
public Node<T> add(T element) {
		Node<T> node = new Node<>(this, element);
		nodes.add(node);
		return node;
	}
1251342
public Object addNode(Node n) {
        //        System.err.println("addNode(" + n + ")");
        if(n.id == null) {
            n.id = handler.handle(this, n);
        }
        return n.id;
    }
254582
def add_node(node, parent):
    '''
    '''
    newNode = dict(node_id=node.id, children=[])
    parent["children"].append(newNode)
    if node.left: add_node(node.left, newNode)
    if node.right: add_node(node.right, newNode)
233493
private void addNthLastChild() {
        for (Node node : nodes) {
            int count = 1;
            Node n = DOMHelper.getNextSiblingElement(node);
            while (n != null) {
                count++;
                n = DOMHelper.getNextSiblingElement(n);
            }
            
            if (specifier.isMatch(count)) {
                result.add(node);
            }
        }
    }
96522
def _add_element(self, element, parent_node):
        
        if element.tag == 'unit':
            element_node_id = element.attrib['id']+':'+element.attrib['type']
            node_layers = {self.ns, self.ns+':unit', self.ns+':'+element.attrib['type']}
        elif element.tag == 'connective':
            element_node_id = element.attrib['id']+':connective'
            node_layers = {self.ns, self.ns+':connective'}
        elif element.tag == 'discourse':
            element_node_id = 'discourse'
            node_layers = {self.ns}
        else:  # <modifier>
            element_node_id = element.getparent().attrib['id']+':'+element.tag
            node_layers = {self.ns, self.ns+':modifier'}

        self.add_node(element_node_id, layers=node_layers)
        self.add_edge(parent_node, element_node_id, layers={self.ns},
                      edge_type=EdgeTypes.dominance_relation)

        if element.text:
            if self.tokenize:
                for token in element.text.split():
                    self._add_token(token, element_node_id)
            else:
                element_text = sanitize_string(element.text)
                self.node[element_node_id].update(
                    {'label': u"{0}: {1}...".format(element_node_id,
                                                   element_text[:20])})


        for child_element in element.iterchildren():
            self._add_element(child_element, element_node_id)

        if element.tail:  # tokens _after_ the </element> closes
            if self.tokenize:
                for token in element.tail.split():
                    self._add_token(token, parent_node)
            else:
                tail_text = sanitize_string(element.tail)
                self.node[parent_node].update(
                    {'label': u"{0}: {1}...".format(parent_node,
                                                    tail_text[:20])})
1365900
def append_sibling_object(self, linenum, indent, path):
        
        frame = self.current_frame()
        assert frame.indent is not None and frame.indent == indent
        self.pop_frame()
        self.append_child_object(linenum, indent, path)
1222503
def _add_nodes(self):
        """"""
        for n, atom in enumerate(self.ast.select('atom')):
            self.add_node(n, atom=atom)
            self._atom_indices[id(atom)] = n
167437
def add_block_as_child_node(self, block, node):
        
        child = etree.SubElement(node, "unknown")
        block.add_xml_to_node(child)