Hey, many thanks for your quick reply.

Not sure how much I should be posting. So here is some code. The names should be self explanatory. The idea is that for the nodes in my osm, I have a traffic value. When parsing ways, I look at the value of consecutive nodes, I take the average value. I compute an effective distance and calculate a beta coefficient from there. If ever a node was encountered with a blocked road I indicate the way as having a beta coef (hence a velocity) of zero.

graphhopper/reader/osm/OSMReader.java:

private final Map<Long, Double> traffic_map = new HashMap<Long, Double>();

if (osmNodeIds.get(0) != osmNodeIds.get(osmNodeIds.size() - 1)) {

for (int i = 0; i < osmNodeIds.size(); i ++) {

if (i < osmNodeIds.size() - 1) {

lat_i = getTmpLatitude(getNodeMap().get(osmNodeIds.get(i)));

lon_i = getTmpLongitude(getNodeMap().get(osmNodeIds.get(i)));

lat_i_plus_one = getTmpLatitude(getNodeMap().get(osmNodeIds.get(i + 1)));

lon_i_plus_one = getTmpLongitude(getNodeMap().get(osmNodeIds.get(i + 1)));

average_traffic = .5*(traffic_map.get(osmNodeIds.get(i)) + traffic_map.get(osmNodeIds.get(i + 1)));

alpha_i = average_traffic/traffic_max;

if (alpha_i == 1.) has_blocked_node = true;

```
distance_i = distCalc.calcDist(lat_i, lon_i, lat_i_plus_one, lon_i_plus_one);
distance += distance_i;
effective_distance += distance_i/Math.max(0.0001, (1. - alpha_i));
}
}
if (has_blocked_node) beta = 0.;
else beta = distance/effective_distance;
}
way.setTag("distance", String.valueOf(distance));
way.setTag("effective_distance", String.valueOf(effective_distance))
way.setTag("beta", String.valueOf(beta));
```

Velocity of the way is modified in the CarFlagEncoder.java file. See below.

graphhopper/routing/util/CarFlagEncoder.java:

Double beta = Double.parseDouble(way.getTag(“beta”));

speed = speed*beta;

Cheers