Improved Code and removed Warnings (#483)

This commit is contained in:
Parth Shandilya
2018-10-19 14:00:31 +05:30
committed by GitHub
parent 07451a6ca4
commit 5d1f72604d
36 changed files with 67 additions and 67 deletions

View File

@ -35,8 +35,8 @@ def BellmanFord(graph, V, E, src):
#MAIN
V = int(input("Enter number of vertices: "))
E = int(input("Enter number of edges: "))
V = int(raw_input("Enter number of vertices: "))
E = int(raw_input("Enter number of edges: "))
graph = [dict() for j in range(E)]
@ -45,10 +45,10 @@ for i in range(V):
for i in range(E):
print("\nEdge ",i+1)
src = int(input("Enter source:"))
dst = int(input("Enter destination:"))
weight = float(input("Enter weight:"))
src = int(raw_input("Enter source:"))
dst = int(raw_input("Enter destination:"))
weight = float(raw_input("Enter weight:"))
graph[i] = {"src": src,"dst": dst, "weight": weight}
gsrc = int(input("\nEnter shortest path source:"))
gsrc = int(raw_input("\nEnter shortest path source:"))
BellmanFord(graph, V, E, gsrc)

View File

@ -38,8 +38,8 @@ def Dijkstra(graph, V, src):
#MAIN
V = int(input("Enter number of vertices: "))
E = int(input("Enter number of edges: "))
V = int(raw_input("Enter number of vertices: "))
E = int(raw_input("Enter number of edges: "))
graph = [[float('inf') for i in range(V)] for j in range(V)]
@ -48,10 +48,10 @@ for i in range(V):
for i in range(E):
print("\nEdge ",i+1)
src = int(input("Enter source:"))
dst = int(input("Enter destination:"))
weight = float(input("Enter weight:"))
src = int(raw_input("Enter source:"))
dst = int(raw_input("Enter destination:"))
weight = float(raw_input("Enter weight:"))
graph[src][dst] = weight
gsrc = int(input("\nEnter shortest path source:"))
gsrc = int(raw_input("\nEnter shortest path source:"))
Dijkstra(graph, V, gsrc)

View File

@ -30,8 +30,8 @@ def FloydWarshall(graph, V):
#MAIN
V = int(input("Enter number of vertices: "))
E = int(input("Enter number of edges: "))
V = int(raw_input("Enter number of vertices: "))
E = int(raw_input("Enter number of edges: "))
graph = [[float('inf') for i in range(V)] for j in range(V)]
@ -40,9 +40,9 @@ for i in range(V):
for i in range(E):
print("\nEdge ",i+1)
src = int(input("Enter source:"))
dst = int(input("Enter destination:"))
weight = float(input("Enter weight:"))
src = int(raw_input("Enter source:"))
dst = int(raw_input("Enter destination:"))
weight = float(raw_input("Enter weight:"))
graph[src][dst] = weight
FloydWarshall(graph, V)