I have a network's data in tabular form (like in the screenshot) and would like to implement the Bellman-Ford algorithm on that. Every existing code for this is implemented to use an adjacency matrix. My file is in the form of an incidence list.
Imported into Julia, the network would be like the following:
start node i,end node j,c_ij
1,2,2
1,3,5
2,3,3
3,4,1
3,5,2
4,1,0
4,5,2
5,2,4
For example, I want to find all the distances from node source = [1,3]
.
My attempt (which is not working):
n = length(start_node)
for k in 1:source
for i in 1:n
for j in 1:n
dist[i][j] = min(W[i][j], W[i][k] + W[k][j])
end
end
end