def measure_dict(net, m="selectivity", d="undirected"): if d == "out": if m == "selectivity": measure = measures.out_selectivity(net) elif m == "degree": g = nx.read_weighted_edgelist(net, create_using=nx.DiGraph()) measure = g.out_degree() elif m == "strength": g = nx.read_weighted_edgelist(net, create_using=nx.DiGraph()) measure = g.out_degree(weight='weight') elif d == "in": if m == "selectivity": measure = measures.in_selectivity(net) elif m == "degree": g = nx.read_weighted_edgelist(net, create_using=nx.DiGraph()) measure = g.in_degree() elif m == "strength": g = nx.read_weighted_edgelist(net, create_using=nx.DiGraph()) measure = g.in_degree(weight='weight') elif d == "undirected": if m == "selectivity": measure = measures.selectivity(net) elif m == "degree": g = nx.read_weighted_edgelist(net) measure = g.degree() elif m == "strength": g = nx.read_weighted_edgelist(net) measure = g.degree(weight='weight') return measure
def entropy(self): parser = argparse.ArgumentParser(prog='entropy', parents=[Measure.parent_parser]) parser.add_argument('measure') args = parser.parse_args(sys.argv[3:]) if args.measure == 'in_selectivity': measure_dict = measures.in_selectivity(args.network) elif args.measure == 'out_selectivity': measure_dict = measures.out_selectivity(args.network) elif args.measure == 'selectivity': measure_dict = measures.selectivity(args.network) elif args.measure == 'in_ipr': measure_dict = measures.in_ipr(args.network) elif args.measure == 'out_ipr': args.measure = measures.out_ipr(args.network) print measures.entropy(measure_dict)