るりまサーチ

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

別のキーワード

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

ライブラリ

モジュール

キーワード

検索結果

TSort.each_strongly_connected_component(each_node, each_child) {|nodes| ...} -> nil (36720.0)

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

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

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

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

@param each_chi...
...ェクトを指定します。

//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) }
TSort.each_strongly_connected_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]
# [2, 3]
# [1]
//}

@see TSort#each_strongly_connected_component...

TSort#each_strongly_connected_component {|nodes| ...} -> nil (36636.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.e...
...ach_strongly_connected_component{|nodes|
p nodes
}

#出力
#=> [4]
#=> [2, 3]
#=> [1]
//}

@see TSort.each_strongly_connected_component...

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

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

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

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

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

@param each_chi...
...ェクトを指定します。

//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) }
TSort.each_strongly_connected_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]
# [2, 3]
# [1]
//}

@see TSort#each_strongly_connected_component...

TSort#each_strongly_connected_component_from(node, id_map={}, stack=[]) -> Enumerator (24626.0)

node から到達可能な強連結成分についてのイテレータです。

...ん。

each_strongly_connected_component
_from は
tsort_each_node を呼びません。

@param node ノードを指定します。

//emlist[例 到達可能なノードを表示する][ruby]{
require 'tsort'

class Hash
i
nclude TSort
alias tsort_each_node each_key
def tsort_each_child(node,...
...non_sort = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}

non_sort.each_strongly_connected_component{|nodes|
p nodes
nodes.each {|node|
non_sort.each_strongly_connected_component_from(node){|ns|
printf("%s -> %s\n", node, ns.join(","))
}
}
}

#出力
#=> [4]
#=> 4 -> 4
#=> [2, 3]
#=> 2 ->...
...4
#=> 2 -> 2,3
#=> 3 -> 4
#=> 3 -> 3,2
#=> [1]
#=> 1 -> 4
#=> 1 -> 2,3
#=> 1 -> 1
//}

@see TSort.each_strongly_connected_component_from...

TSort#each_strongly_connected_component_from(node, id_map={}, stack=[]) {|nodes| ...} -> () (24626.0)

node から到達可能な強連結成分についてのイテレータです。

...ん。

each_strongly_connected_component
_from は
tsort_each_node を呼びません。

@param node ノードを指定します。

//emlist[例 到達可能なノードを表示する][ruby]{
require 'tsort'

class Hash
i
nclude TSort
alias tsort_each_node each_key
def tsort_each_child(node,...
...non_sort = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}

non_sort.each_strongly_connected_component{|nodes|
p nodes
nodes.each {|node|
non_sort.each_strongly_connected_component_from(node){|ns|
printf("%s -> %s\n", node, ns.join(","))
}
}
}

#出力
#=> [4]
#=> 4 -> 4
#=> [2, 3]
#=> 2 ->...
...4
#=> 2 -> 2,3
#=> 3 -> 4
#=> 3 -> 3,2
#=> [1]
#=> 1 -> 4
#=> 1 -> 2,3
#=> 1 -> 1
//}

@see TSort.each_strongly_connected_component_from...

絞り込み条件を変える

TSort.each_strongly_connected_component_from(node, each_child, id_map={}, stack=[]) -> Enumerator (24620.0)

node から到達可能な強連結成分についてのイテレータです。

...と each_child でグラフを表します。

返す値は規定されていません。

TSort.each_strongly_connected_component_fromはTSortをincludeして
グラフを表現する必要のないクラスメソッドです。

@param node ノードを指定します。

@param each_child 引数...
...//emlist[使用例][ruby]{
require 'tsort'

graph = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}
each_child = lambda {|n, &b| graph[n].each(&b) }
TSort.each_strongly_connected_component_from(1, each_child) {|scc|
p scc
}
# => [4]
# [2, 3]
# [1]
//}

@see TSort#each_strongly_connected_component_from...

TSort.each_strongly_connected_component_from(node, each_child, id_map={}, stack=[]) {|nodes| ...} -> () (24620.0)

node から到達可能な強連結成分についてのイテレータです。

...と each_child でグラフを表します。

返す値は規定されていません。

TSort.each_strongly_connected_component_fromはTSortをincludeして
グラフを表現する必要のないクラスメソッドです。

@param node ノードを指定します。

@param each_child 引数...
...//emlist[使用例][ruby]{
require 'tsort'

graph = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}
each_child = lambda {|n, &b| graph[n].each(&b) }
TSort.each_strongly_connected_component_from(1, each_child) {|scc|
p scc
}
# => [4]
# [2, 3]
# [1]
//}

@see TSort#each_strongly_connected_component_from...

tsort (30.0)

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

...e

//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
#=...
...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_strongly_connected_component
_fr...
...分に関するアルゴリズムを使っているからです。
とはいえ strongly_connected_components という正確な名前は長過ぎます。

=== References
R. E. Tarjan,
Depth First Search and Linear Graph Algorithms,
SIAM Journal on Computing, Vol. 1, No. 2, pp. 146-160, June 1972....