Esempio n. 1
0
def algorithm(graph, flow):
    src = flow.src_num
    dst = flow.dst_num
    required_bandwidth = flow.bandwidth

    print "3: path computing"
    shortest_paths = path_computing(graph, src, dst, k=4)
    shortest_paths.sort(key=len)
    # print "the result of disjoint paths for src %s and dst %s:" % (src, dst),
    # print shortest_paths

    print "4: spectrum assigning"
    paths_occupied_spectrum = routing_and_spectrum(graph, shortest_paths,
                                                   required_bandwidth)
    # print "all routing path and occupied slots %s" % paths_occupied_spectrum

    if paths_occupied_spectrum is not None:
        flow.paths = paths_occupied_spectrum
        working_path = paths_occupied_spectrum[0][0]
        for i in range(len(working_path) - 1):
            graph[working_path[i]][working_path[i + 1]]['flows'].append(flow)
            # print "add flow to working path",
            # print graph[working_path[i]][working_path[i+1]]['flows']

    # print "the graph after the spectrum assignment:"
    # print graph.edges(data=True)
    return paths_occupied_spectrum
Esempio n. 2
0
def get_disjoint_test():
    switch_pairs = {(1, 2, 1), (1, 3, 2), (2, 4, 1), (3, 4, 2), (4, 5, 1), (5, 6, 2), (2, 6, 2)}

    for pair in switch_pairs:
        flows = []
        slots_list = total_slots * [0]
        graph.add_edge(pair[0], pair[1], weight=pair[2], spectrum_slots=slots_list, flows=flows)
        graph.add_edge(pair[1], pair[0], weight=pair[2], spectrum_slots=slots_list, flows=flows)
    print graph.edges(data=True)

    shortest_paths = path_computing(graph, 2, 5, k=1)
    shortest_paths.sort(key=len)
    print "the result of disjoint paths for src %s and dst %s:" % (2, 5),
    print shortest_paths
    return graph
Esempio n. 3
0
def algorithm(graph, flow):
    src = flow.src_num
    dst = flow.dst_num
    required_bandwidth = flow.bandwidth

    print "3: path computing"
    shortest_paths = path_computing(graph, src, dst, k=4)
    shortest_paths.sort(key=len)
    # print "the result of disjoint paths for src %s and dst %s:" % (src, dst),
    print shortest_paths

    print "4: spectrum assigning"
    paths_occupied_spectrum = routing_and_spectrum(graph, shortest_paths, required_bandwidth)
    # print "all routing path and occupied slots %s" % paths_occupied_spectrum
    # print "the graph after the spectrum assignment %s" % graph.edges(data=True)

    return paths_occupied_spectrum