Example #1
0
#!/usr/bin/env python
import cc
from topo.os3e import OS3EGraph

g = OS3EGraph()

link_fail_prob = 0.01
print "OS3E"
print "sssp: %03f" % cc.compute(g, link_fail_prob, 0, 1, 'sssp')
print "any: %03f" % cc.compute(g, link_fail_prob, 0, 1, 'any')
Example #2
0
import networkx as nx

from cc import compute, sssp_conn
from topo.os3e import OS3EGraph

link_fail_prob = 0.001
ALGS = [sssp_conn] # ['sssp', 'any']

g = OS3EGraph()

uptimes = {}
for alg in ALGS:
    uptimes[alg] = []
    lines = uptimes[alg]
    uptime, conn_data = compute(g, link_fail_prob, 0, 1, alg)
    dc = nx.degree_centrality(g)
    cc = nx.closeness_centrality(g)
    bc = nx.betweenness_centrality(g)
    ec = nx.eigenvector_centrality(g)
    #print conn_data
    tuples = []
    for key, val in conn_data.iteritems():
        tuples.append((key, val, dc[key], cc[key], bc[key], ec[key]))

    tuples = sorted(tuples, key = itemgetter(1), reverse = True)
    for vals in tuples:
        print "%016s %1.5f %05f %05f %05f %05f" % vals

    # check if cc is ordered
    bc_prev = 1.0
Example #3
0
# Graph generators: given a size, generate a graph.
graph_types = {
    'complete': (lambda n: complete_graph(n)),
    'star': (lambda n: star_graph(n - 1)),
    'line': (lambda n: path_graph(n)),
    'loop': (lambda n: loop_graph(n))
}

f = open(FILENAME, 'w')

data = {}

algs = ['sssp', 'any']
for alg in algs:
    data[alg] = {}
    for gtype, fcn in graph_types.iteritems():
        values = []
        for i in range(3, 11):
            link_fail = 0.01
            node_fail = 0.0
            max_fail = 1
            g = fcn(i)
            uptime, conn_data = compute(g, link_fail, node_fail, max_fail, alg)
            values.append((i, uptime))
        data[alg][gtype] = values

print data

json.dump(data, f)
Example #4
0
#!/usr/bin/env python
'''Create data for plot comparing algorithm uptimes on Internet2 graph.'''

import json

import cc
from topo.os3e import OS3EGraph

FILENAME = "os3e_link.json"

MAX_LINK_FAIL_PROB = 0.02
LINK_FAIL_INCREMENT = 0.002
ALGS = ['sssp', 'any']

f = open(FILENAME, 'w')

g = OS3EGraph()

uptimes = {}
for alg in ALGS:
    uptimes[alg] = []
    lines = uptimes[alg]
    for i in range(1, int(MAX_LINK_FAIL_PROB / LINK_FAIL_INCREMENT)):
        link_fail_prob = i * LINK_FAIL_INCREMENT
        uptime, conn_data = cc.compute(g, link_fail_prob, 0, 1, alg)
        lines.append((link_fail_prob, uptime))
        print "%s %03f %03f" % (alg, link_fail_prob, uptime)

json.dump(uptimes, f)