som/basic_som.py
def distance_squared(self, node1, node2):
        """Calculates the squared distance between two nodes on the torus."""
        dr = abs(node1.row - node2.row)
        dc = abs(node1.col - node2.col)
        return (min(dr, abs(dr - self.height)) ** 2
                + min(dc, abs(dc - self.width)) ** 2)
Calculates the squared distance between two nodes on the torus.
Calculates the squared distance between two nodes on the torus.
Calculates the squared distance between two nodes on the torus .
def distance_squared(self, node1, node2):
        dr = abs(node1.row - node2.row)
        dc = abs(node1.col - node2.col)
        return (min(dr, abs(dr - self.height)) ** 2
                + min(dc, abs(dc - self.width)) ** 2)
def distance_squared ( self , node1 , node2 ) : dr = abs ( node1 . row - node2 . row ) dc = abs ( node1 . col - node2 . col ) return ( min ( dr , abs ( dr - self . height ) ) ** 2 + min ( dc , abs ( dc - self . width ) ) ** 2 )
Calculates the squared distance between two nodes on the torus.
Calculates the squared distance between two nodes on the torus .
"""Calculates the squared distance between two nodes on the torus."""
self
node1
node2