lib/rgl/traversal.rb in rgl-0.6.3 vs lib/rgl/traversal.rb in rgl-0.6.4
- old
+ new
@@ -115,10 +115,12 @@
# This method uses the +tree_edge_event+ of BFSIterator
# to record all tree edges of the search tree in the result.
#
# @return [DirectedAdjacencyGraph] which represents a BFS search tree starting at _v_.
def bfs_search_tree_from(v)
- require 'rgl/adjacency'
+ unless defined?(DirectedAdjacencyGraph)
+ require 'rgl/adjacency'
+ end
bfs = bfs_iterator(v)
tree = DirectedAdjacencyGraph.new
bfs.set_tree_edge_event_handler do |from, to|
tree.add_edge(from, to)