Sha256: f7ca89eb49edfba45d900eab769153683cf5fd1b538c11345d47f65df537346b
Contents?: true
Size: 1.34 KB
Versions: 3
Compression:
Stored size: 1.34 KB
Contents
require 'test/unit' require 'yargi' module Yargi class VertexSetTest < Test::Unit::TestCase module Center; end module AtOne; end module AtTwo; end def setup @star = Yargi::Digraph.new @center = @star.add_vertex(Center) @atone = @star.add_n_vertices(10, AtOne) @attwo = @star.add_n_vertices(10, AtTwo) @star.connect(@center, @atone) @atone.zip(@attwo).each do |pair| @star.connect(pair[0], pair[1]) end #puts @star.to_dot end def test_in_and_out_edges assert_equal [], VertexSet[@center].in_edges assert_equal @atone.in_edges, VertexSet[@center].out_edges assert_equal @attwo.in_edges, @atone.out_edges end def test_in_and_out_edges_no_duplicate @star.connect(@atone, @atone) assert_equal @atone.in_edges, @atone.in_edges.uniq assert_equal @atone.out_edges, @atone.out_edges.uniq assert_equal @atone, VertexSet[@center].out_edges.target sortproc = Kernel.lambda {|v1,v2| v1.index <=> v2.index} assert_equal (@atone+@attwo).sort(&sortproc), @atone.out_edges.target.sort(&sortproc) assert_equal @atone.sort(&sortproc), @atone.out_edges.source.sort(&sortproc) assert_equal (@atone+[@center]).sort(&sortproc), @atone.in_edges.source.sort(&sortproc) end end # class VertexSetTest end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
yargi-0.1.2 | test/yargi/vertex_set_test.rb |
yargi-0.1.0 | test/yargi/vertex_set_test.rb |
yargi-0.1.1 | test/yargi/vertex_set_test.rb |