示例#1
0
    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
    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)