def add_to_data(name, g, i, t, data): g = get_topo_graph(name) print ">>>%s: %s of %s" % (name, i, t) de = GraphData(name=name, n=g.number_of_nodes(), e=g.number_of_edges(), ad=g.number_of_edges() / float(g.number_of_nodes()), ic=nx.is_connected(g), c=nx.number_connected_components(g), w=total_weight(g) if has_weights(g) else 0) data.append(de) print "\t" + str(de)
def add_to_data(name, g, i, t, data): g = get_topo_graph(name) print ">>>%s: %s of %s" % (name, i, t) de = GraphData(name = name, n = g.number_of_nodes(), e = g.number_of_edges(), ad = g.number_of_edges() / float(g.number_of_nodes()), ic = nx.is_connected(g), c = nx.number_connected_components(g), w = total_weight(g) if has_weights(g) else 0) data.append(de) print "\t" + str(de)
def print_topo_stats(name, g): n = g.number_of_nodes() e = g.number_of_edges() ad = 2.0 * g.number_of_edges() / float(g.number_of_nodes()) ic = nx.is_connected(g) c = nx.number_connected_components(g) w = total_weight(g) if has_weights(g) else 0 if COMPACT: print "%s: %s %s %.1f %s %s %.1f" % (name, n, e, ad, ic, c, w) else: print "***********" print "topo name: %s" % name print "number of nodes: %s" % n print "number of edges: %s" % e print "average degree: %.1f" % ad print "is connected: %s" % ic print "connected components: %s" % c print "total weight: %.1f" % w
g, usable, note = get_topo_graph(topo) cc = nx.number_connected_components(g) controllers = metrics.get_controllers(g, options) exp_filename = metrics.get_filename(topo, options, controllers) if not g: raise Exception("WTF? null graph: %s" % topo) if options.topos_blacklist and topo in options.topos_blacklist: print("ignoring topo %s - in blacklist" % topo) ignored.append(topo) elif cc != 1: # Ignore multiple-CC topos, which confuse APSP calcs print("ignoring topo, cc != 1: %s" % topo) ignored.append(topo) elif g.number_of_nodes() < len(controllers): print("skipping topo, c >= n: %s" % topo) ignored.append(topo) elif not options.force and os.path.exists(exp_filename + '.json'): # Don't bother doing work if our metrics are already there. print("skipping already-analyzed topo: %s" % topo) ignored.append(topo) elif not has_weights(g): ignored.append(topo) print("no weights for %s, skipping" % topo) else: do_all(topo, g, 1, 1, None) successes.append(topo) print("successes: %s of %s: %s" % (len(successes), t, successes)) print("ignored: %s of %s: %s" % (len(ignored), t, ignored))
print "topo %s of %s: %s" % (i + 1, t, topo) g, usable, note = get_topo_graph(topo) cc = nx.number_connected_components(g) controllers = metrics.get_controllers(g, options) exp_filename = metrics.get_filename(topo, options, controllers) if not g: raise Exception("WTF? null graph: %s" % topo) if options.topos_blacklist and topo in options.topos_blacklist: print "ignoring topo %s - in blacklist" % topo ignored.append(topo) elif cc != 1: # Ignore multiple-CC topos, which confuse APSP calcs print "ignoring topo, cc != 1: %s" % topo ignored.append(topo) elif g.number_of_nodes() < len(controllers): print "skipping topo, c >= n: %s" % topo ignored.append(topo) elif not options.force and os.path.exists(exp_filename + '.json'): # Don't bother doing work if our metrics are already there. print "skipping already-analyzed topo: %s" % topo ignored.append(topo) elif not has_weights(g): ignored.append(topo) print "no weights for %s, skipping" % topo else: do_all(topo, g, 1, 1, None) successes.append(topo) print "successes: %s of %s: %s" % (len(successes), t, successes) print "ignored: %s of %s: %s" % (len(ignored), t, ignored)