lib/nanoc/base/directed_graph.rb in nanoc-3.6.7 vs lib/nanoc/base/directed_graph.rb in nanoc-3.6.8
- old
+ new
@@ -7,25 +7,25 @@
#
# @example Creating and using a directed graph
#
# # Create a graph with three vertices
# graph = Nanoc::DirectedGraph.new(%w( a b c d ))
- #
+ #
# # Add edges
# graph.add_edge('a', 'b')
# graph.add_edge('b', 'c')
# graph.add_edge('c', 'd')
- #
+ #
# # Get (direct) predecessors
# graph.direct_predecessors_of('d').sort
# # => %w( c )
# graph.predecessors_of('d').sort
# # => %w( a b c )
- #
+ #
# # Modify edges
# graph.delete_edge('a', 'b')
- #
+ #
# # Get (direct) predecessors again
# graph.direct_predecessors_of('d').sort
# # => %w( c )
# graph.predecessors_of('d').sort
# # => %w( b c )
@@ -34,11 +34,11 @@
# @group Creating a graph
# Creates a new directed graph with the given vertices.
def initialize(vertices)
@vertices = {}
- vertices.each_with_index do |v,i|
+ vertices.each_with_index do |v, i|
@vertices[v] = i
end
@from_graph = {}
@to_graph = {}
@@ -100,10 +100,10 @@
#
# @return [void]
#
# @since 3.2.0
def add_vertex(v)
- return if @vertices.has_key?(v)
+ return if @vertices.key?(v)
@vertices[v] = @vertices.size
@roots << v
end