pysal/pysal — pull request #349 by jlaura (2013-09-25 20:38:22+00:00)
Title: Added W generation

Added KNN and threshold generated W objects on the network. Updated ReadMe.

- KNN
1. For the set of nodes V in the network compute Dijkstra's for all other nodes.
2. Use heapq.nsmallest to get the n smallest
3. Remove the 0 distance source node
4. Get the indices
5. Pass to `pysal.W(neighbors, ids=ids)` to generate the W

- Threshold
1. For the set of nodes, V, in the network compute Dijkstra's until we pop a node with distance greater than the threshold.
2. Compute weights if necessary.
3. Pass to `pysal.W(neighbors, weights, ids=ids)` to generate the W.

Notes
-----
- KNN equal distance breaks are arbitrary
- Distances are computed from the source node to the destination node. Thresholding therefore requires traversal of the full edge to be included as a neighbor. We could parameterize such that as long as 1/2 the node distance is traversable, we include. This introduces starting at the mid point of the initial edge as well, so perhaps is better handled as a kernel.