This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'pqueue' | |
class Graph | |
attr_reader :edges | |
INFINITY = 1 << 32 | |
def initialize(size) | |
@edges = Array.new(size) {Array.new(size)} | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
class BinaryTree | |
include Enumerable | |
attr_accessor :key, :data, :left, :right | |
def initialize(h) # assume h is form {:key => k, :data=>d} | |
@key = @data = nil | |
assign_key_data(h) | |
@left = @right = nil |