I would like to make a graph algorithm that updates/computes
the value of a node f(n) as a function of each of the f(n) values of
neighboring nodes.
- The graph is directed.
- Each node has as initial f(n) value.
- Each edge has NO cost (0).
- The value of each node is the maximum of its current value and the value of each neighboring nodes (directed graph, so neighbors are the ones from where the node has incoming edges).
More formally,
f(n) = max(f(n),max_i(f(n_i))), where i from neighbor 1 to neighbor k.
I can visualize a few ways of doing so, however I do not know to what extend they are optimal.
Can anyone please give suggestions and commentaries (whether do you think your suggestion is optimal) or suggest any existent graph algorithm I can adapt?
max()has a summation inside of it. I am not sure I understand what c(n,n_i) is (I think it is a weight for edge) - but if could make the function not converge. Have a look on the graph:a<-1->b(two nodes, with an edge of cost 1 from a to b and an edge of cost 1 from b to a). Regardless of the initial cost ofaandb, the function f(a) and f(b) will go to infinity, because every iteration is adding 1. - amit