public void recomputeInformationAvailability(SocialGroup sg) { int CUTOFF = 128; HashSet <Location> closed = new HashSet <Location>(); List <Location> working = new List <Location>(); List <double> distances = new List <double>(); foreach (Location a in locations) { if (a.soc == sg) { closed.Add(a); working.Add(a); double dist = 1; distances.Add(dist); a.information.set(sg, dist); } } int steps = 0; while (working.Count > 0) { steps += 1; if (steps >= CUTOFF) { break; } List <Location> next = new List <Location>(); List <double> nextDistances = new List <double>(); for (int i = 0; i < working.Count; i++) { Location l = working[i]; double dist = distances[i]; dist *= l.getInformationAvailability(); dist = Math.Max(param.minInformationAvailability, dist); l.information.set(sg, dist); foreach (Location n in l.getNeighbours()) { if (closed.Contains(n)) { continue; } closed.Add(n); nextDistances.Add(dist); next.Add(n); } } working = next; distances = nextDistances; } }