Ejemplo n.º 1
0
    return nodes


def maxCC(ccs):

    max = 0
    for cc in ccs:
        if len(cc) > max:
            max = len(cc)

    return max


graph = None
if opts.network.endswith(".sif"):
    graph = convert.read_sif(open(opts.network))
else:
    graph = convert.read_spf(open(opts.network))

heats = parseHeats(opts.heats)
if opts.cut_graph and not opts.node_attributes:
    cut_val = None
    try:
        cutoff = float(opts.cut_graph)
    except:
        raise Exception(
            "Error: value supplied to cut_graph must be a positive number")

    cutG = cutGraph(graph, heats, cutoff)
    convert.write_sif(cutG, sys.stdout)
    sys.exit(0)
Ejemplo n.º 2
0
        current = update
    return current


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("network", default=None)
    parser.add_argument("values", default=None)
    parser.add_argument("--cycles", type=int, default=10)
    parser.add_argument("--timestep", type=float, default=0.0001)
    parser.add_argument("--header", action="store_true", default=False)
        
    args = parser.parse_args()

    handle = open(args.network)
    gr = networkx.Graph(convert.read_sif(handle))
    handle.close()

    val = read_vec_file(args.values)

    current = {}
    for n in gr.node:
        current[n] = val.get(n, None)

    found = True
    while found:
        update = {}
        found = False
        for n in current:
            if current[n] is not None:
                update[n] = current[n]
Ejemplo n.º 3
0
		nodes.add(target)
	
	return nodes
	
def maxCC(ccs):

	max = 0
	for cc in ccs:
		if len(cc) > max:
			max = len(cc)

	return max

graph = None
if opts.network.endswith(".sif"):
	graph = convert.read_sif(open(opts.network))
else:
	graph = convert.read_spf(open(opts.network))

heats = parseHeats(opts.heats)
if opts.cut_graph and not opts.node_attributes:
	cut_val = None
	try:
		cutoff = float(opts.cut_graph)
	except:
		raise Exception("Error: value supplied to cut_graph must be a positive number")

	cutG = cutGraph(graph, heats, cutoff)
	convert.write_sif(cutG, sys.stdout)
	sys.exit(0)