[BioRuby-cvs] bioruby/lib/bio tree.rb,1.6,1.7

Naohisa Goto ngoto at dev.open-bio.org
Fri Jan 12 16:10:30 UTC 2007


Update of /home/repository/bioruby/bioruby/lib/bio
In directory dev.open-bio.org:/tmp/cvs-serv30847/lib/bio

Modified Files:
	tree.rb 
Log Message:
* fixed a bug: clear_node did not work correctly.
* NotAdjacentNodesError is removed.
* insert_node is changed to raise IndexError when the edge does not found.
* remove_edge is changed to raise IndexError when the edge does not found.


Index: tree.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/tree.rb,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** tree.rb	15 Dec 2006 18:45:17 -0000	1.6
--- tree.rb	12 Jan 2007 16:10:28 -0000	1.7
***************
*** 26,32 ****
      class NoPathError < RuntimeError; end
  
-     # Error when the two nodes are not adjacent.
-     class NotAdjacentNodesError < RuntimeError; end
- 
      # Edge object of each node.
      # By default, the object doesn't contain any node information.
--- 26,29 ----
***************
*** 412,415 ****
--- 409,413 ----
          @pathway.graph[k].delete(node)
        end
+       @pathway.graph[node].clear
        self
      end
***************
*** 440,443 ****
--- 438,443 ----
  
      # Removes an edge between source and target.
+     # Returns self.
+     # If the edge does not exist, raises IndexError.
      #---
      # If two or more edges exists between source and target,
***************
*** 445,448 ****
--- 445,451 ----
      #+++
      def remove_edge(source, target)
+       unless self.get_edge(source, target) then
+         raise IndexError, 'edge not found'
+       end
        fwd = [ source, target ]
        rev = [ target, source ]
***************
*** 815,819 ****
      #
      # Returns self.
!     # If node1 and node2 are not adjacent, raises NotAdjacentNodesError.
      #
      # If new_node already exists in the tree, the tree would become
--- 818,822 ----
      #
      # Returns self.
!     # If node1 and node2 are not adjacent, raises IndexError.
      #
      # If new_node already exists in the tree, the tree would become
***************
*** 822,826 ****
      def insert_node(node1, node2, new_node, new_distance = nil)
        unless edge = self.get_edge(node1, node2) then
!         raise NotAdjacentNodesError, 'node1 and node2 are not adjacent.'
        end
        new_edge = Edge.new(new_distance)
--- 825,829 ----
      def insert_node(node1, node2, new_node, new_distance = nil)
        unless edge = self.get_edge(node1, node2) then
!         raise IndexError, 'nodes not found or two nodes are not adjacent'
        end
        new_edge = Edge.new(new_distance)




More information about the bioruby-cvs mailing list