Let's say I have a set of N towns and a road network that connects the towns. I think some towns might an influence on other towns because they meet some criterion. I have a binary indicator of this criterion (e.g., crit==1 or crit==0) for each town.
I want to construct a new variable that is a measure of how much each town might be influenced by it's neighbors, giving more weight to closer towns with a value of crit==1. I could define neighborhood as all towns within D km driving distance or R km radius.
What is the best tool in this case? Conceptually, I thought a spatial weights matrix might be useful, but I don't want a NxN matrix. I want a Nx1 matrix where the vector of values is a measure of how much each town might be influenced by its neighbors.
I created a toy example on GitHub.