Method: Bio::Tree#remove_edge

Defined in:
lib/bio/tree.rb

#remove_edge(source, target) ⇒ Object

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, all of them are removed. +++



465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
# File 'lib/bio/tree.rb', line 465

def remove_edge(source, target)
  unless self.get_edge(source, target) then
    raise IndexError, 'edge not found'
  end
  _clear_cache
  fwd = [ source, target ]
  rev = [ target, source ]
  @pathway.relations.delete_if do |rel|
    rel.node == fwd or rel.node == rev
  end
  h = @pathway.graph[source]
  h.delete(target) if h
  h = @pathway.graph[target]
  h.delete(source) if h
  self
end