class RGL::BipartiteBFSIterator
Attributes
bipartite_sets_map[R]
found_odd_cycle[R]
Public Instance Methods
handle_back_edge(u, v)
click to toggle source
# File lib/rgl/bipartite.rb, line 70 def handle_back_edge(u, v) verify_odd_cycle(u, v) end
handle_forward_edge(u, v)
click to toggle source
# File lib/rgl/bipartite.rb, line 74 def handle_forward_edge(u, v) verify_odd_cycle(u, v) end
handle_tree_edge(u, v)
click to toggle source
# File lib/rgl/bipartite.rb, line 66 def handle_tree_edge(u, v) @bipartite_sets_map[v] = (@bipartite_sets_map[u] + 1) % 2 unless u.nil? # put v into the other set end
reset()
click to toggle source
Calls superclass method
# File lib/rgl/bipartite.rb, line 48 def reset super @bipartite_sets_map = {} @found_odd_cycle = false end
reset_start(new_start)
click to toggle source
# File lib/rgl/bipartite.rb, line 61 def reset_start(new_start) @start_vertex = new_start set_to_begin end
set_to_begin()
click to toggle source
Calls superclass method
# File lib/rgl/bipartite.rb, line 55 def set_to_begin super @bipartite_sets_map[@start_vertex] = 0 end
Private Instance Methods
verify_odd_cycle(u, v)
click to toggle source
# File lib/rgl/bipartite.rb, line 80 def verify_odd_cycle(u, v) u_set = @bipartite_sets_map[u] @found_odd_cycle = true if u_set && u_set == @bipartite_sets_map[v] end