44件ヒット
[1-44件を表示]
(0.349秒)
種類
- 特異メソッド (11)
- ライブラリ (11)
- 文書 (11)
- インスタンスメソッド (11)
ライブラリ
- tsort (22)
モジュール
- TSort (22)
キーワード
-
NEWS for Ruby 2
. 1 . 0 (11) - tsort (11)
検索結果
先頭4件
-
TSort
. strongly _ connected _ components(each _ node , each _ child) -> Array (18220.0) -
強連結成分の集まりを配列の配列として返します。 この配列は子から親に向かってソートされています。 各要素は強連結成分を表す配列です。
...&b| g[n].each(&b) }
p TSort.strongly_connected_components(each_node, each_child)
# => [[4], [2], [3], [1]]
g = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}
each_node = lambda {|&b| g.each_key(&b) }
each_child = lambda {|n, &b| g[n].each(&b) }
p TSort.strongly_connected_components(each_node, each_child)
# =>......[[4], [2, 3], [1]]
//}
@see TSort#strongly_connected_components... -
TSort
# strongly _ connected _ components -> Array (18214.0) -
強連結成分の集まりを配列の配列として返します。 この配列は子から親に向かってソートされています。 各要素は強連結成分を表す配列です。
...rt'
class Hash
include TSort
alias tsort_each_node each_key
def tsort_each_child(node, &block)
fetch(node).each(&block)
end
end
non_sort = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}
p non_sort.strongly_connected_components
#=> [[4], [2, 3], [1]]
//}
@see TSort.strongly_connected_components... -
NEWS for Ruby 2
. 1 . 0 (24.0) -
NEWS for Ruby 2.1.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...よるメソッド定義式は nil の代わりにメソッド名をシンボルで返します
=== 組み込みクラスの更新
* Array
* 追加: Array#to_h キーと値のペアの配列をハッシュに変換します。
* Binding
* 追加: Binding#local_variable_get
* 追......ときは string-scrub gem を使います。
* Symbol
* 全てのシンボルは freeze されるようになりました
* pack/unpack (Array/String)
* プラットフォームが対応していれば Q! と q! は long long 型を表します
* toplevel
* main.using はもは......内部で rescue されなくなりました。
* tsort
* 追加: TSort#tsort
* 追加: TSort#tsort_each
* 追加: TSort#strongly_connected_components
* 追加: TSort#each_strongly_connected_component
* 追加: TSort#each_strongly_connected_component_from
* webrick
*... -
tsort (24.0)
-
tsort はトポロジカルソートと強連結成分に関するモジュールを提供します。
...k)
fetch(node).each(&block)
end
end
{1=>[2, 3], 2=>[3], 3=>[], 4=>[]}.tsort
#=> [3, 2, 1, 4]
{1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}.strongly_connected_components
#=> [[4], [2, 3], [1]]
//}
=== より現実的な例
非常に単純な `make' に似たツールは以下のように実装でき......ed_component_from(target) {|ns|
if ns.length != 1
fs = ns.delete_if {|n| Array === n}
raise TSort::Cyclic.new("cyclic dependencies: #{fs.join ', '}")
end
n = ns.first
if Array === n
outputs, inputs, block = n
inputs_time = inputs.map {|f| File.......なら
このライブラリは Tarjan の強連結成分に関するアルゴリズムを使っているからです。
とはいえ strongly_connected_components という正確な名前は長過ぎます。
=== References
R. E. Tarjan,
Depth First Search and Linear Graph Algorithms,
SIAM Journal...