るりまサーチ

最速Rubyリファレンスマニュアル検索!
54件ヒット [1-54件を表示] (0.453秒)
トップページ > クエリ:i[x] > クエリ:key[x] > クエリ:strongly_connected_components[x]

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

ライブラリ

モジュール

キーワード

検索結果

TSort.strongly_connected_components(each_node, each_child) -> Array (18231.0)

強連結成分の集まりを配列の配列として返します。 この配列は子から親に向かってソートされています。 各要素は強連結成分を表す配列です。

...す配列です。

引数 each_node と each_child でグラフを表します。

@param each_node グラフ上の頂点をそれぞれ評価するcallメソッドを持つオブ
ジェクトを指定します。

@param each_child 引数で与えられた頂点の子をそれぞ...
...ェクトを指定します。

//emlist[使用例][ruby]{
require 'tsort'

g = {1=>[2, 3], 2=>[4], 3=>[2, 4], 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]]

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.each_strongly_connected_component(each_node, each_child) {|nodes| ...} -> nil (228.0)

TSort.strongly_connected_components メソッドのイテレータ版です。

...TSort.strongly_connected_components メソッドのイテレータ版です。

引数 each_node と each_child でグラフを表します。

@param each_node グラフ上の頂点をそれぞれ評価するcallメソッドを持つオブ
ジェクトを指定します。

@param...
...ach_child 引数で与えられた頂点の子をそれぞれ評価するcallメソッ
ドを持つオブジェクトを指定します。

//emlist[使用例][ruby]{
require 'tsort'

g = {1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}
each_node = lambda {|&b| g.each_key(&b) }
each_child = l...
..._component(each_node, each_child) {|scc| p scc }

# => [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) }
TSort.each_strongly_connected_component(each_node, each_child) {|scc| p scc }

# => [4]...

TSort#each_strongly_connected_component {|nodes| ...} -> nil (138.0)

TSort#strongly_connected_components メソッドのイテレータ版です。 obj.each_strongly_connected_component は obj.strongly_connected_components.each に似ていますが、 ブロックの評価中に obj が変更された場合は予期しない結果になる ことがあります。

...TSort#strongly_connected_components メソッドのイテレータ版です。
obj.each_strongly_connected_component は
obj.strongly_connected_components.each に似ていますが、
ブロックの評価中に obj が変更された場合は予期しない結果になる
ことがあります。...
...each_strongly_connected_component は nil を返します。

//emlist[使用例][ruby]{
require 'tsort'

class Hash
i
nclude 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=>[]}

non_sort...

TSort.each_strongly_connected_component(each_node, each_child) -> Enumerator (128.0)

TSort.strongly_connected_components メソッドのイテレータ版です。

...TSort.strongly_connected_components メソッドのイテレータ版です。

引数 each_node と each_child でグラフを表します。

@param each_node グラフ上の頂点をそれぞれ評価するcallメソッドを持つオブ
ジェクトを指定します。

@param...
...ach_child 引数で与えられた頂点の子をそれぞれ評価するcallメソッ
ドを持つオブジェクトを指定します。

//emlist[使用例][ruby]{
require 'tsort'

g = {1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}
each_node = lambda {|&b| g.each_key(&b) }
each_child = l...
..._component(each_node, each_child) {|scc| p scc }

# => [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) }
TSort.each_strongly_connected_component(each_node, each_child) {|scc| p scc }

# => [4]...

tsort (30.0)

tsort はトポロジカルソートと強連結成分に関するモジュールを提供します。

...//emlist[][ruby]{
require 'tsort'

class Hash
i
nclude TSort
alias tsort_each_node each_key
def tsort_each_child(node, &block)
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
#=>...
...きます。

//emlist[][ruby]{
require 'tsort'

class Make
def initialize
@dep = {}
@dep.default = []
end

def rule(outputs, inputs=[], &block)
triple = [outputs, inputs, block]
outputs.each {|f| @dep[f] = [triple]}
@dep[triple] = inputs
end

def build(target)
each...
...ns|
i
f ns.length != 1
fs = ns.delete_if {|n| Array === n}
raise TSort::Cyclic.new("cyclic dependencies: #{fs.join ', '}")
end
n = ns.first
i
f Array === n
outputs, inputs, block = n
i
nputs_time = inputs.map {|f| File.mtime f}.max
begin...

絞り込み条件を変える