Add a link to a network. Links are what effectively
            define the network topology, by associating two already
            existing nodes.
431902
def add_link(self, name, desc, layout, node_1, node_2):
        

        existing_link = get_session().query(Link).filter(Link.name==name, Link.network_id==self.id).first()
        if existing_link is not None:
            raise HydraError("A link with name %s is already in network %s"%(name, self.id))

        l = Link()
        l.name        = name
        l.description = desc
        l.layout           = json.dumps(layout) if layout is not None else None
        l.node_a           = node_1
        l.node_b           = node_2

        get_session().add(l)

        self.links.append(l)

        return l
1197485
public void addLink(String linkName, Link link) {
		if (links == null) {
			links = new Links(new HashMap<String, Link>());
		}
		links.addLink(linkName, link);
	}
1333111
def add_to_group(link, group_name = nil)
      add_to = root
      add_to = group_name.split('.').inject(root) { |group, name| group.send(name) } if group_name
      add_to << link unless link.nil?
    end
762539
def addNode(self, node):
        
        LOGGER.info('Adding node {}({})'.format(node.name, node.address))
        message = {
            'addnode': {
                'nodes': [{
                    'address': node.address,
                    'name': node.name,
                    'node_def_id': node.id,
                    'primary': node.primary,
                    'drivers': node.drivers,
                    'hint': node.hint
                }]
            }
        }
        self.send(message)
885600
public void add(N node) {
        if (! node.added) {
            nodes.add(node);
            node.added = true;
        }
    }
98367
def add_node(self, node_name):
        
        graph = self.graph
        if node_name in graph:
            raise KeyError('node %s already exists' % node_name)
        graph[node_name] = set()
1140252
def link(self, x,y,w,h,link):
        ""
        if not self.page in self.page_links:
            self.page_links[self.page] = []
        self.page_links[self.page] += [(x*self.k,self.h_pt-y*self.k,w*self.k,h*self.k,link),]
744461
def add_node_to_network(self, node, network):
        """"""
        network.add_node(node)
        node.receive()

        environment = network.nodes(type=Environment)[0]
        environment.connect(whom=node)

        gene = node.infos(type=LearningGene)[0].contents
        if (gene == "social"):
            prev_agents = RogersAgent.query\
                .filter(and_(RogersAgent.failed == False,
                             RogersAgent.network_id == network.id,
                             RogersAgent.generation == node.generation - 1))\
                .all()
            parent = random.choice(prev_agents)
            parent.connect(whom=node)
            parent.transmit(what=Meme, to_whom=node)
        elif (gene == "asocial"):
            environment.transmit(to_whom=node)
        else:
            raise ValueError("{} has invalid learning gene value of {}"
                             .format(node, gene))
        node.receive()
1260234
function addRelToGraph(node){
    var children = [];
    for (var prop in node){
        if(node.hasOwnProperty(prop)){
            if (typeof node[prop] === 'object') {

                var linkedNodes = node[prop];
                // same for links
                if (colorsByLinkType[prop] == null) {
                    colorsByLinkType[prop] = getRandomColor();
                }
                
                for (var i = 0; i < linkedNodes.length; i++) {
                    //find node by id in the array (using jQuery)
                    const linkedNode = linkedNodes[i];
                    var nodeResult = getNodeFromId(linkedNode);
                    gChildrenNodes.push(nodeResult);
                    children.push(nodeResult);
                    //if the node is displayed, we add a link otherwise we will need to add it later
                    if (contains(gNodesDisplayed, nodeResult)){
                        g.addLink(node._id, nodeResult._id, prop);
                    } else {
                        nodesToBeLinked[nodeResult._id] = delayLinkCreation(node._id, nodeResult._id, prop);
                    }


                }
            }
        }
    }
    gNodesWithChildren[node._id] = children;
}
331599
def add_node(self, node):
        """"""
        nodes = [n for n in self.nodes() if not isinstance(n, Source)]
        num_agents = len(nodes)
        curr_generation = int((num_agents - 1) / float(self.generation_size))
        node.generation = curr_generation

        if curr_generation == 0:
            if self.initial_source:
                source = min(
                    self.nodes(type=Source),
                    key=attrgetter('creation_time'))
                source.connect(whom=node)
                source.transmit(to_whom=node)
        else:
            prev_agents = Node.query\
                .filter_by(failed=False,
                           network_id=self.id,
                           generation=(curr_generation - 1))\
                .all()
            prev_fits = [p.fitness for p in prev_agents]
            prev_probs = [(f / (1.0 * sum(prev_fits))) for f in prev_fits]

            rnd = random.random()
            temp = 0.0
            for i, probability in enumerate(prev_probs):
                temp += probability
                if temp > rnd:
                    parent = prev_agents[i]
                    break

            parent.connect(whom=node)
            parent.transmit(to_whom=node)
919970
def _add_complex(self, members, is_association=False):
        """"""
        params = {'color': '#0000ff',
                  'arrowhead': 'dot',
                  'arrowtail': 'dot',
                  'dir': 'both'}
        for m1, m2 in itertools.combinations(members, 2):
            if self._has_complex_node(m1, m2):
                continue
            if is_association:
                m1_key = _get_node_key(m1.concept)
                m2_key = _get_node_key(m2.concept)
            else:
                m1_key = _get_node_key(m1)
                m2_key = _get_node_key(m2)
            edge_key = (set([m1_key, m2_key]), 'complex')
            if edge_key in self.existing_edges:
                return
            self.existing_edges.append(edge_key)
            self._add_edge(m1_key, m2_key, **params)
120540
public void add(Mtp2 link) {
        // add link at the first empty place
        for (int i = 0; i < links.length; i++) {
            if (links[i] == null) {
                links[i] = link;
                break;
            }
        }
        count++;
        remap();
    }
288114
def add_bond(self, key1, key2, bond):
        """"""
        self.graph.add_edge(key1, key2, bond=bond)
666613
def add_node(self, c):
        
        idx = len(self.nodes)
        self.edges[idx] = set()
        self.nodes.append(c)
        return idx
487246
def add_chain(self, *nodes, _input=BEGIN, _output=None, _name=None):
        
        if len(nodes):
            _input = self._resolve_index(_input)
            _output = self._resolve_index(_output)
            _first = None
            _last = None

            for i, node in enumerate(nodes):
                _last = self.add_node(node)
                if not i and _name:
                    if _name in self.named:
                        raise KeyError("Duplicate name {!r} in graph.".format(_name))
                    self.named[_name] = _last
                if _first is None:
                    _first = _last
                self.outputs_of(_input, create=True).add(_last)
                _input = _last

            if _output is not None:
                self.outputs_of(_input, create=True).add(_output)

            if hasattr(self, "_topologcally_sorted_indexes_cache"):
                del self._topologcally_sorted_indexes_cache

            return GraphRange(self, _first, _last)
        return GraphRange(self, None, None)
1111746
def addInternalLink(self, link):
        '''
        
        '''
        if isinstance(link, InternalLink):
            self.internalLinks.append(link)
        else:
            raise InternalLinkError( 
                'link Type should be InternalLink, not %s' % type(link))
271988
def add_prefix(network):
    
    p = new_prefix()
    p.prefix = str(network['network'])
    p.type = "assignment"
    p.description = network['description']
    p.tags = ['ipplan-import']
    p.comment = ""

    if 'additional' in network:
        p.comment += network['additional']
    if len(network['comment']) > 0:
        p.comment += network['comment']
    return p