module MiniGraph

Constants

VERSION

Public Class Methods

bfs(graph, start_at: nil) click to toggle source
# File lib/mini_graph.rb, line 33
def self.bfs(graph, start_at: nil)
  MiniGraph::DSL::SearchContext.evaluate(graph, start_at, algorithm: :bfs)
end
create(*vertices, &block) click to toggle source

Used to construct a new graph.

Example usage:

jim   = Person.new
john  = Person.new
jill  = Person.new
jane  = Person.new

friends = MiniGraph.create(jim, john, jill, jane) do
  # Creates a directed graph
  directed!

  edge from: jim,   to: [john, jill, jane]
  edge from: john,  to: [jill, jane]
  edge from: jane,  to: jill
end
# File lib/mini_graph.rb, line 25
def self.create(*vertices, &block)
  MiniGraph::DSL::GraphContext.evaluate(*vertices, &block)
end
dfs(graph, start_at: nil) click to toggle source
# File lib/mini_graph.rb, line 29
def self.dfs(graph, start_at: nil)
  MiniGraph::DSL::SearchContext.evaluate(graph, start_at, algorithm: :dfs)
end