pysal / spaghetti

SPAtial GrapHs: nETworks, Topology, & Inference
http://pysal.org/spaghetti/
BSD 3-Clause "New" or "Revised" License
271 stars 70 forks source link

alldistances vs. distancematrix? #351

Closed jGaboardi closed 4 years ago

jGaboardi commented 4 years ago

Refactor the storage of the spaghetti.Network.alldistances and spaghetti.Network.distancematrix attributes. These currently are redundant and can be combined into one attribute.

see: here and here

jGaboardi commented 4 years ago

If a distance matrix is desired, keep method for exporting it. Something like:

def export_distance_matrix(self):
    nvtx = len(self.alldistances)
    matrix = numpy.empty((nvtx, nvtx))
    for idx, data in self.alldistances.items():
        matrix[idx,:] = data[0]
    return matrix
jGaboardi commented 4 years ago

Decided to ditch the alldistances attribute and keep the distancematrix attribute (renamed distance_matrix) + store the trees/paths in a new attribute: network_trees. This will save a considerable amount of RAM because we will no longer be storing a full nXm distance matrix (distancematrix) and each row of the distance matrix as the first tuple item of the alldistances dictionary values.

jGaboardi commented 4 years ago

370