lib/ruby_algorithms/containers/graphs/graph.rb
def print_edges
    @edge.each do |u, edges_of_u|
      edges_of_u.each { |k,v| puts "{#{k}, #{v}}" }
    end
  end
# Let g be a graph with n nodes and m edges. g.print_edges runs in practice in
# order of m time. By contrast, in a pure adjacency-matrix based approach, it
# would run in order of n^2 time. So this is much faster for sparseness (i.e. m <<
# n^2)
Let g be a graph with n nodes and m edges. g.print_edges runs in practice in
order of m time. By contrast, in a pure adjacency-matrix based approach, it
would run in order of n^2 time. So this is much faster for sparseness
Let g be a graph with n nodes and m edges . g . print_edges runs in practice in order of m time . By contrast in a pure adjacency - matrix based approach it would run in order of n^2 time . So this is much faster for sparseness
def print_edges
    @edge.each do |u, edges_of_u|
      edges_of_u.each { |k,v| puts "{#{k}, #{v}}" }
    end
  end
def print_edges @edge . each do | u , edges_of_u | edges_of_u . each { | k , v | puts "{#{k}, #{v}}" } end end
Let g be a graph with n nodes and m edges.
Let g be a graph with n nodes and m edges .