Returns all neighbors of a model.
483860
private List<ODocument> getNeighborsOfModel(String model) {
        String query = String.format("select from Models where in.out.%s in [?]", OGraphDatabase.LABEL);
        List<ODocument> neighbors = graph.query(new OSQLSynchQuery<ODocument>(query), model);
        return neighbors;
    }
216510
protected COPACModel computeLocalModel(DBIDRef id, DoubleDBIDList knnneighbors, Relation<V> relation) {
    PCAResult epairs = settings.pca.processIds(knnneighbors, relation);
    int pdim = settings.filter.filter(epairs.getEigenvalues());
    PCAFilteredResult pcares = new PCAFilteredResult(epairs.getEigenPairs(), pdim, 1., 0.);

    double[][] mat = pcares.similarityMatrix();
    double[] vecP = relation.get(id).toArray();
    if(pdim == vecP.length) {
      // Full dimensional - noise!
      return new COPACModel(pdim, DBIDUtil.EMPTYDBIDS);
    }

    // Check which neighbors survive
    HashSetModifiableDBIDs survivors = DBIDUtil.newHashSet();
    for(DBIDIter neighbor = relation.iterDBIDs(); neighbor.valid(); neighbor.advance()) {
      double[] diff = minusEquals(relation.get(neighbor).toArray(), vecP);
      double cdistP = transposeTimesTimes(diff, mat, diff);
      if(cdistP <= epsilonsq) {
        survivors.add(neighbor);
      }
    }
    return new COPACModel(pdim, survivors);
  }
488398
def _get_vertices_neighbours(nets):
    
    zero_fn = (lambda: 0)
    vertices_neighbours = defaultdict(lambda: defaultdict(zero_fn))
    for net in nets:
        if net.weight != 0:
            for sink in net.sinks:
                vertices_neighbours[net.source][sink] += net.weight
                vertices_neighbours[sink][net.source] += net.weight
    return vertices_neighbours
484124
def _get_all_relationships(self):
        """"""
        relationships_all = set()
        for goterm in self.go2obj.values():
            if goterm.relationship:
                relationships_all.update(goterm.relationship)
            if goterm.relationship_rev:
                relationships_all.update(goterm.relationship_rev)
        return relationships_all
100401
private void calculateNearestNeighbors(int nn) {
        int n = this.dimension;
        if ((nn > 0) && (nn < n)) {
            nearestNeighbors = new int[n][nn];

            Neighbor[] neighbors = new Neighbor[n];
            for (int i = 0; i < n; i++) neighbors[i] = new Neighbor();

            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    neighbors[j].id = j;
                    neighbors[j].distance = this.distances[i][j];
                }
                neighbors[i].distance = Integer.MAX_VALUE;
                Arrays.sort(neighbors);
                for (int j = 0; j < nn; j++) nearestNeighbors[i][j] = neighbors[j].id;
            }
        }
     }
1201810
def neighbors( open_list=[], closed_list=[] )
      i,j = free_cell      
      up = moved_matrix_with_parent(i, j, i-1, j, open_list, closed_list)
      down = moved_matrix_with_parent(i, j, i+1, j, open_list, closed_list)
      left = moved_matrix_with_parent(i, j, i, j-1, open_list, closed_list)
      right = moved_matrix_with_parent(i, j, i, j+1, open_list, closed_list)

      moved = []
      moved << up if !up.nil? 
      moved << down if !down.nil? 
      moved << left if !left.nil? 
      moved << right if !right.nil? 

      return moved
    end
832534
def _get_model_nodes(self, model):
        
        nodes = [(name, node) for name, node in model._nodes.items()
                if node._is_auto_created is False]
        nodes.sort(key=lambda n: n[0])
        return nodes
556507
def mu(self):
        """"""
        mu = self._models[0].mu
        assert all([mu == model.mu for model in self._models])
        return mu
272206
def get_networks(network_id=None):
    """"""
    session = db.get_reader_session()
    with session.begin():
        model = models_v2.Network
        networks = session.query(model).filter(model.project_id != '')
        if network_id:
            networks = networks.filter(model.id == network_id)
    return networks.all()
1331467
def select_neighbors_by_edge_attribute(docgraph, source,
                                       attribute=None, value=None, data=False):
    """"""
    assert isinstance(docgraph, MultiGraph)
    for neighbor_id in docgraph.neighbors_iter(source):
        edges = docgraph[source][neighbor_id].values()

        if attribute is None:
            has_attrib = True # don't filter neighbors
        else:
            has_attrib = any(attribute in edge for edge in edges)

        if has_attrib:
            if value is None:
                has_value = True
            elif isinstance(value, basestring):
                has_value = any(edge.get(attribute) == value
                                for edge in edges)
            else:  # ``value`` is a list/set/dict of values
                has_value = any(edge.get(attribute) == v
                                for edge in edges
                                for v in value)

            if has_value:
                if data:
                    yield (neighbor_id, docgraph.node[neighbor_id])
                else:
                    yield neighbor_id
939218
def atlas_get_all_neighbors( peer_table=None ):
    
    if os.environ.get("BLOCKSTACK_ATLAS_NETWORK_SIMULATION") != "1":
        raise Exception("This method is only available when testing with the Atlas network simulator")

    ret = {}

    with AtlasPeerTableLocked(peer_table) as ptbl:
        ret = copy.deepcopy(ptbl)

    # make zonefile inventories printable
    for peer_hostport in ret.keys():
        if ret[peer_hostport].has_key('zonefile_inv'):
            ret[peer_hostport]['zonefile_inv'] = atlas_inventory_to_string( ret[peer_hostport]['zonefile_inv'] )

    return ret
1253169
def get_neighbors(distance_matrix, source, eps):
    

    return [dest for dest, distance in enumerate(distance_matrix[source]) if distance < eps]
1243449
def neighbors(self, **kwargs):

        
        urn = "{urn:brocade.com:mgmt:brocade-lldp-ext}"

        result = []
        has_more = ''
        last_ifindex = ''
        rbridge_id = None
        if 'rbridge_id' in kwargs:
            rbridge_id = kwargs.pop('rbridge_id')
        while (has_more == '') or (has_more == 'true'):
            request_lldp = self.get_lldp_neighbors_request(last_ifindex,
                                                           rbridge_id)
            lldp_result = self._callback(request_lldp, 'get')
            has_more = lldp_result.find('%shas-more' % urn).text

            for item in lldp_result.findall('%slldp-neighbor-detail' % urn):
                local_int_name = item.find('%slocal-interface-name' % urn).text
                local_int_mac = item.find('%slocal-interface-mac' % urn).text
                last_ifindex = item.find(
                    '%slocal-interface-ifindex' % urn).text
                remote_int_name = item.find(
                    '%sremote-interface-name' % urn).text
                remote_int_mac = item.find('%sremote-interface-mac' % urn).text
                remote_chas_id = item.find('%sremote-chassis-id' % urn).text
                try:
                    remote_sys_name = item.find(
                        '%sremote-system-name' % urn).text
                except AttributeError:
                    remote_sys_name = ''
                try:
                    remote_sys_desc = item.find('%sremote-system-description' %
                                                urn).text
                except AttributeError:
                    remote_sys_desc = ''
                try:
                    remote_mgmt_addr = item.find(
                        '%sremote-management-address' %
                        urn).text
                except AttributeError:
                    remote_mgmt_addr = ''
                if 'Fo ' in local_int_name:
                    local_int_name = local_int_name.replace(
                        'Fo ',
                        'FortyGigabitEthernet '
                    )
                if 'Te ' in local_int_name:
                    local_int_name = local_int_name.replace(
                        'Te ',
                        'TenGigabitEthernet '
                    )

                item_results = {'local-int-name': local_int_name,
                                'local-int-mac': local_int_mac,
                                'remote-int-name': remote_int_name,
                                'remote-int-mac': remote_int_mac,
                                'remote-chassis-id': remote_chas_id,
                                'remote-system-name': remote_sys_name,
                                'remote-system-description': remote_sys_desc,
                                'remote-management-address': remote_mgmt_addr}
                result.append(item_results)

        return result
741879
def find_face_neighbors(face)
      raise "not a face" unless face.is_a?(Face)
      neighbors = find_neighbors(face.vertices)
      neighbors - [face]
    end
1133883
def find_model(object):
        

        models = []
        for model in GraphModel._GraphModel__models_instances.itervalues():
            for node in foundations.walkers.nodes_walker(model.root_node):
                if node is object:
                    models.append(model)

                for attribute in node.get_attributes():
                    if attribute is object:
                        models.append(model)
        return models
684930
def neighbors(self, key):
        """"""
        return {n: attr["bond"] for n, attr in self.graph[key].items()}
1038405
def _get_fields_for_model(model):
    
    fields = []
    for name in model._sa_class_manager:
        prop = getattr(model, name)
        if isinstance(prop.property, RelationshipProperty):
            for pk in prop.property.mapper.primary_key:
                fields.append('{0}.{1}'.format(name, pk.name))
        else:
            fields.append(name)
    return tuple(fields)