예제 #1
0
def ddeg(f):
    '''Main driver to solve this problem.'''
    return ro.join_list(double_deg(rg.read_edgelist(ro.iterlines(f))))
예제 #2
0
def cc(f):
    '''Main driver to solve this problem.'''
    return len(connected_components(read_graph(ro.iterlines(f))))
예제 #3
0
def read_data(f):
    '''Read input file. Return a list of candidate proteins and target mass spectrum.'''
    n = int(open(f, 'rb').next())
    return np.array(list(it.islice(ro.iterlines(f), 1, n + 1))), np.loadtxt(f, skiprows=n + 1)
예제 #4
0
def pcov(f):
    '''Main driver to solve this problem.'''
    return perfect_coverage_recon(ro.iterlines(f))
예제 #5
0
def trie(f):
    '''Main driver to solve this problem.'''
    Trie(ro.iterlines(f)).write_edgelist()
예제 #6
0
def read_data(f):
    '''Return s,k, edge list iterator. Nodes are converted to 0-based numbers,
    string start to 0-based.'''
    lines = ro.iterlines(f)
    return lines.next(), int(lines.next()), it.imap(lambda x: (int(x[0][4:]) - 1, int(x[1][4:]) - 1, (int(x[2]) - 1, int(x[3]))), (x.split() for x in lines))
예제 #7
0
def qrt(f):
    """Main driver to solve this problem."""
    lines = ro.iterlines(f)
    s = next(lines).split()
    for q in quartets(s, lines):
        print "{%s, %s} {%s, %s}" % tuple(map(s.__getitem__, sum(q, ())))
예제 #8
0
def solve_maj(f):
    return ro.join_list(it.imap(majority_element, it.imap(ro.to_int_list, ro.skip(ro.iterlines(f), 1))))
예제 #9
0
def deg(f):
    '''Main driver to solve this problem.'''
    g = rg.read_edgelist(ro.iterlines(f))
    return ' '.join(map(str, (g.degree(u) for u in xrange(1, g.number_of_nodes() + 1))))