コード例 #1
0
ファイル: CartesianTopology.py プロジェクト: nahumj/seeds
    def within_range(self, node1, node2, distance, periodic):
        """Determine whether or not two nodes are within a given distance from
        each other

        Parameters:

        *node1*
            The first node (tuple)
        *node2*
            The second node (tuple)
        *distance*
            The threshold distance 
        *periodic*
            Whether or not periodic boundary conditions are used.

        """

        return euclidean_distance(node1, node2, periodic) < distance
コード例 #2
0
ファイル: CartesianTopology.py プロジェクト: namlehai/seeds
    def within_range(self, node1, node2, distance, periodic):
        """Determine whether or not two nodes are within a given distance from
        each other

        Parameters:

        *node1*
            The first node (tuple)
        *node2*
            The second node (tuple)
        *distance*
            The threshold distance 
        *periodic*
            Whether or not periodic boundary conditions are used.

        """

        return euclidean_distance(node1, node2, periodic) < distance
コード例 #3
0
ファイル: Topology.py プロジェクト: nahumj/seeds
    def node_distance(self, src, dest):
        """Calculate the Euclidean distance between the given two nodes using
        their 'coords' properties

        Parameters:

        *src*
            The first node ID
        *dest*
            The second node ID

        If either node does not exist, NonExistentNodeError will be raised

        """

        if src not in self.graph.nodes():
            raise NonExistentNodeError(src)
        elif dest not in self.graph.nodes():
            raise NonExistentNodeError(dest)

        return euclidean_distance(self.graph.node[src]['coords'],
                                  self.graph.node[dest]['coords'],
                                  periodic=self.periodic)
コード例 #4
0
    def node_distance(self, src, dest):
        """Calculate the Euclidean distance between the given two nodes using
        their 'coords' properties

        Parameters:

        *src*
            The first node ID
        *dest*
            The second node ID

        If either node does not exist, NonExistentNodeError will be raised

        """

        if src not in self.graph.nodes():
            raise NonExistentNodeError(src)
        elif dest not in self.graph.nodes():
            raise NonExistentNodeError(dest)

        return euclidean_distance(self.graph.node[src]['coords'],
                                  self.graph.node[dest]['coords'],
                                  periodic=self.periodic)