Given connections between nodes set minimum distance from nodeI
| 44 | |
| 45 | // Given connections between nodes set minimum distance from nodeI |
| 46 | void Foam::router::setWeights |
| 47 | ( |
| 48 | const label weight, |
| 49 | const label nodeI |
| 50 | ) |
| 51 | { |
| 52 | // Set weight at current node |
| 53 | weights_[nodeI] = weight; |
| 54 | |
| 55 | const labelList& myNeighbours = connections_[nodeI]; |
| 56 | |
| 57 | forAll(myNeighbours, neighbourI) |
| 58 | { |
| 59 | if (weights_[myNeighbours[neighbourI]] > weight + 1) |
| 60 | { |
| 61 | // Distribute weight+1 to neighbours |
| 62 | setWeights |
| 63 | ( |
| 64 | weight+1, |
| 65 | myNeighbours[neighbourI] |
| 66 | ); |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | |
| 72 | // Mark shortest path from endNode to startNode by setting the weights |