Example #1
0
 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)
Example #2
0
 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)
Example #3
0
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
Example #4
0
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
Example #5
0
    # plot_data[ptype][metric] = [dict of topo data, keyed by metric]
    # each value includes:
    # x: list of sorted controller k's
    # lines: dict of y-axis lists, keyed by aspect
    plot_data = {}
    # CSV format:
    csv_fields = ['metric', 'ptype', 'name', 'topo', 'n', 'e', 'w', 'gdf_name', 'x', 'y']
    csv_tuples = []
    for i, topo in enumerate(topos):
        if not options.max == None and i >= options.max:
            break

        g, usable, note = get_topo_graph(topo)

        if usable:
            w = total_weight(g)

            # Check for --force here?
            print "usable topo: %s" % topo
            total_usable += 1
            controllers = metrics.get_controllers(g, options)
            exp_filename = metrics.get_filename(topo, options, controllers)

            path_exists = os.path.exists(exp_filename + '.json')
            compute_metrics = 'metrics' in options.operations

            # Compute data only when the following conditions hold:
            # - asked to complete metrics, AND
            # - asked to force, or data is missing
            if compute_metrics and (options.force or not path_exists):
                print "freshly analyzing topo: %s" % topo