Skip to content

Commit

Permalink
Added Dijkstra test
Browse files Browse the repository at this point in the history
  • Loading branch information
bkmukhej committed Nov 13, 2016
1 parent 520b2e2 commit 1d6fbbf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
20 changes: 11 additions & 9 deletions Dijkstra2.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,16 @@ def gen_graph(cost_matrix):
g.addEdge(i,j,cost_matrix[i][j])
return g

cost_matrix = [[0, 4, 0, 0, 0, 0, 0, 8, 0],[4, 0, 8, 0, 0, 0, 0, 11, 0],[0, 8, 0, 7, 0, 4, 0, 0, 2],[0, 0, 7, 0, 9, 14, 0, 0, 0],[0, 0, 0, 9, 0, 10, 0, 0, 0],[0, 0, 4, 14, 10, 0, 2, 0, 0],[0, 0, 0, 0, 0, 2, 0, 1, 6],[8, 11, 0, 0, 0, 0, 1, 0, 7],[0, 0, 2, 0, 0, 0, 6, 7, 0]]
#print(cost_matrix)
g = gen_graph(cost_matrix)
#print("Before Dijkstra-------------")
#show_graph(g)
dijkstra2(g,g.vertices[0])
#print("After Dijkstra--------------")
#show_graph(g)
print(get_path(g,g.vertices[0],g.vertices[4]))
def test_Dijkstra():
cost_matrix = [[0, 4, 0, 0, 0, 0, 0, 8, 0],[4, 0, 8, 0, 0, 0, 0, 11, 0],[0, 8, 0, 7, 0, 4, 0, 0, 2],[0, 0, 7, 0, 9, 14, 0, 0, 0],[0, 0, 0, 9, 0, 10, 0, 0, 0],[0, 0, 4, 14, 10, 0, 2, 0, 0],[0, 0, 0, 0, 0, 2, 0, 1, 6],[8, 11, 0, 0, 0, 0, 1, 0, 7],[0, 0, 2, 0, 0, 0, 6, 7, 0]]
#print(cost_matrix)
g = gen_graph(cost_matrix)
#print("Before Dijkstra-------------")
#show_graph(g)
dijkstra2(g,g.vertices[0])
#print("After Dijkstra--------------")
#show_graph(g)
print(get_path(g,g.vertices[0],g.vertices[4]))
return


4 changes: 2 additions & 2 deletions RouteManagement.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from Topo_Specs import switch_port_mac_dict as mac_dict,dpid_switch_number as sw_num,switch_port_mat, switch_number_dpid as sw_dpid
from QoSApplication import switch_dict
from Topo_Specs import switch_port_mac_dict as mac_dict,dpid_switch_number as sw_num,switch_port_mat, switch_number_dpid as sw_dpid, switch_dict
#from QoSApplication import switch_dict

class RouteManagement():
flow_counter = 0
Expand Down

0 comments on commit 1d6fbbf

Please sign in to comment.