I am trying to find the longest path of a DAG from vertex 0. After searching on Stackoverflow, I understand that I can invert the weighting of the edges and use the Bellman Ford algorithm to find the longest path. However, I don't fully understand how this works.
My graph however has no weighting (all are equal), I assume I should just set to -1?
I am using networkx and python to solve this. Here is my Bellman code:
def Bellman(G):
pred, dist = nx.bellman_ford(G, 0, weight='-1')
print(dist)
No matter what weight I set, I still get the lowest distance for every node from 0. Where am I going wrong?