Sha256: 136b860ed14b78eeacc41971186be7f100f5a2d52d5823dfabb72bd90f7c9610

Contents?: true

Size: 600 Bytes

Versions: 2

Compression:

Stored size: 600 Bytes

Contents

require 'test/unit'
require 'rgl/transitiv_closure'

include RGL

class Array
  alias add push
end

class TestTransitiveClosure < Test::Unit::TestCase

  def setup
    @dg = DirectedAdjacencyGraph.new(Array)
	edges = [[1,2],[2,3],[2,4],[4,5],[1,6],[6,4]]
    edges.each do |(src,target)| 
      @dg.add_edge(src, target)
    end
  end

  def test_transitive_closure
	assert_equal("(1-2)(1-3)(1-4)(1-6)(2-3)(2-4)(2-5)(4-5)(6-4)(6-5)",
				 @dg.transitive_closure.to_s)
  end

  def test_transitive_closure_undirected
	assert_raises(NotDirectedError) {AdjacencyGraph.new.transitive_closure}
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rgl-0.2.2 tests/TestTransitiveClosure.rb
rgl-0.2.3 tests/TestTransitiveClosure.rb