def is_component(w, ids):
components = <NUM_LIT:0><EOL>marks = dict([(node, <NUM_LIT:0>) for node in ids])<EOL>q = []<EOL>for node in ids:<EOL><INDENT>if marks[node] == <NUM_LIT:0>:<EOL><INDENT>components += <NUM_LIT:1><EOL>q.append(node)<EOL>if components > <NUM_LIT:1>:<EOL><INDENT>return False<EOL><DEDENT><DEDENT>while q:<EOL><INDENT>node = q.pop()<EOL>marks[node] = components<EOL>others = [neighbor for neighbor in w.neighbors[node]<EOL>if neighbor in ids]<EOL>for other in others:<EOL><INDENT>if marks[other] == <NUM_LIT:0> and other not in q:<EOL><INDENT>q.append(other)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>return True<EOL>
Check if the set of ids form a single connected component

    Parameters
    ----------

    w   : spatial weights boject

    ids : list
          identifiers of units that are tested to be a single connected
          component


    Returns
    -------

    True    : if the list of ids represents a single connected component

    False   : if the list of ids forms more than a single connected component