# effigies/PyMVPA forked from PyMVPA/PyMVPA

STY Indented comment string and added citations for Dijkstra implemen…

`…tation`
1 parent e248442 commit 2eb2ce092902973d1d5a451db84ea740b0b89407 committed Aug 1, 2012
Showing with 11 additions and 3 deletions.
1. +11 −3 mvpa2/misc/neighborhood.py
@@ -395,6 +395,10 @@ def __getitem__(self, coordinate):
return idcs
def dijkstra(self, G, start, end=None):
+ """Dijkstra's algorithm for shortest paths
+ Modified from version by David Eppstein, UC Irvine, 4 Apr 2002
+
+ Original source: http://code.activestate.com/recipes/119466"""

#### yarikoptic Aug 1, 2012

I just wonder how it would compare to networkx's single_source_dijkstra_path_length ?
https://networkx.lanl.gov/trac/browser/networkx/networkx/algorithms/shortest_paths/weighted.py#L171

ideally we should be just reusing other's work ;)

D = {} # dictionary of final distances
Q = priorityDictionary() # est.dist. of non-final vert.
Q[start] = 0
@@ -417,6 +421,10 @@ def dijkstra(self, G, start, end=None):
class priorityDictionary(dict):
+ """Priority dictionary using binary heaps
+ Modified from version by David Eppstein, UC Irvine, 8 Mar 2002
+
+ Original source: http://code.activestate.com/recipes/117228"""

#### yarikoptic Aug 1, 2012

Copyright: 2002, David Eppstein, UC Irvine

def __init__(self):
self.__heap = []
dict.__init__(self)
@@ -451,9 +459,9 @@ def iterfn():
return iterfn()
def __setitem__(self, key, val):
- '''Change value stored in dictionary and add corresponding
-pair to heap. Rebuilds the heap if the number of deleted items grows
-too large, to avoid memory leakage.'''
+ '''Change value stored in dictionary and add corresponding pair to
+ heap. Rebuilds the heap if the number of deleted items grows too large,
+ to avoid memory leakage.'''
dict.__setitem__(self, key, val)
heap = self.__heap
if len(heap) > 2 * len(self):