Module: Graphos::Weighted::TextFactory
- Defined in:
- lib/graphos/weighted/text_factory.rb
Class Method Summary collapse
Class Method Details
.read(path) ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'lib/graphos/weighted/text_factory.rb', line 4 def self.read path f = File.open(path,"r") graph = Graph.new(f.gets.to_i) while(line=f.gets) args = line.split(/[ \n]+/) graph.add_edge args[0].to_i-1, args[1].to_i-1, args[2].to_f end graph end |