Class: CycleDetector::DKWonMLPrintStrategy
- Inherits:
-
Object
- Object
- CycleDetector::DKWonMLPrintStrategy
- Defined in:
- lib/kwala/lib/cycle_detector.rb
Instance Method Summary collapse
-
#initialize ⇒ DKWonMLPrintStrategy
constructor
A new instance of DKWonMLPrintStrategy.
- #print_cycles(cycles) ⇒ Object
- #print_graph(graph) ⇒ Object
Constructor Details
#initialize ⇒ DKWonMLPrintStrategy
Returns a new instance of DKWonMLPrintStrategy.
550 551 552 553 554 555 |
# File 'lib/kwala/lib/cycle_detector.rb', line 550 def initialize @visited = Hash.new(false) @edges = [] @nodeid = Hash.new @cid = 0 end |
Instance Method Details
#print_cycles(cycles) ⇒ Object
569 570 571 572 573 574 575 576 577 578 579 |
# File 'lib/kwala/lib/cycle_detector.rb', line 569 def print_cycles(cycles) print_ml_wrapper do if cycles.size > 0 cycles.each do |path| puts "Nothing" end end end end |
#print_graph(graph) ⇒ Object
557 558 559 560 561 562 563 564 565 566 567 |
# File 'lib/kwala/lib/cycle_detector.rb', line 557 def print_graph(graph) print_ml_wrapper do noedge, edge = graph.sort.partition { |k,v| v.edges.empty? } (edge + noedge).each do |k, v| print_node(v) end end end |