Page 1 of 1

DCP-466: Sanvi and TreeMap.....bfs problem

PostPosted: Sun Feb 04, 2018 2:32 am
by shawonchy123
In the editorial it says this problem could be solved by bfs.but this is a weighted graph.how do i implement bfs to find the distance between two nodes in a weighted graph.i knew that bfs can not be implement in a weighted graph.

Re: DCP-466: Sanvi and TreeMap.....bfs problem

PostPosted: Thu Feb 15, 2018 4:01 am
by feodorv
"but this is a weighted graph"

There is a weighted tree! So it is possible.

But i see no need in such algorithms. Single beforehand calculated matrix dist[5][5] can be useful.