種類
- 特異メソッド (42)
- インスタンスメソッド (32)
- ライブラリ (11)
- 文書 (11)
ライブラリ
- tsort (74)
モジュール
- TSort (74)
キーワード
-
NEWS for Ruby 2
. 1 . 0 (11) -
each
_ strongly _ connected _ component _ from (42) - tsort (11)
検索結果
先頭5件
- TSort
. each _ strongly _ connected _ component(each _ node , each _ child) {|nodes| . . . } -> nil - TSort
# each _ strongly _ connected _ component {|nodes| . . . } -> nil - TSort
. each _ strongly _ connected _ component(each _ node , each _ child) -> Enumerator - TSort
# each _ strongly _ connected _ component _ from(node , id _ map={} , stack=[]) -> Enumerator - TSort
# each _ strongly _ connected _ component _ from(node , id _ map={} , stack=[]) {|nodes| . . . } -> ()
-
TSort
. each _ strongly _ connected _ component(each _ node , each _ child) {|nodes| . . . } -> nil (18320.0) -
TSort.strongly_connected_components メソッドのイテレータ版です。
...ータ版です。
引数 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) }
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 (18236.0) -
TSort#strongly_connected_components メソッドのイテレータ版です。 obj.each_strongly_connected_component は obj.strongly_connected_components.each に似ていますが、 ブロックの評価中に obj が変更された場合は予期しない結果になる ことがあります。
...obj.each_strongly_connected_component は
obj.strongly_connected_components.each に似ていますが、
ブロックの評価中に obj が変更された場合は予期しない結果になる
ことがあります。
each_strongly_connected_component は nil を返します。
//emlist[使用......例][ruby]{
require 'tsort'
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=>[]}
non_sort.each_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 (18220.0) -
TSort.strongly_connected_components メソッドのイテレータ版です。
...ータ版です。
引数 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) }
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 (6226.0) -
node から到達可能な強連結成分についてのイテレータです。
...ん。
each_strongly_connected_component_from は
tsort_each_node を呼びません。
@param node ノードを指定します。
//emlist[例 到達可能なノードを表示する][ruby]{
require 'tsort'
class Hash
include TSort
alias tsort_each_node each_key
def tsort_each_child(node,......d
end
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| . . . } -> () (6226.0) -
node から到達可能な強連結成分についてのイテレータです。
...ん。
each_strongly_connected_component_from は
tsort_each_node を呼びません。
@param node ノードを指定します。
//emlist[例 到達可能なノードを表示する][ruby]{
require 'tsort'
class Hash
include TSort
alias tsort_each_node each_key
def tsort_each_child(node,......d
end
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 (6220.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| . . . } -> () (6220.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... -
NEWS for Ruby 2
. 1 . 0 (42.0) -
NEWS for Ruby 2.1.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...報があるため短いです。
十分な情報と共に書かれた全ての変更のリストは ChangeLog ファイルか bugs.ruby-lang.org の issue を参照してください。
== 2.0.0 以降の変更
=== 言語仕様の変更
* キーワード引数のデフォルト値が省略可......尾に'r','i','ri'という接尾辞を付けられるようになりました
//emlist{
# r を付けると有理数になる
42r # => Rational(42, 1)
3.14 # => 3.14.rationalize
6.022e+23r # 指数形式と一緒には使えない
# i を付けると虚数単位 i を掛けた......TSort#each_strongly_connected_component
* 追加: TSort#each_strongly_connected_component_from
* webrick
* レスポンスボディは readpartial や read をサポートする StringIO か他の IO のようなオブジェクトになりました。
* xmlrpc
* XMLRPC::Client... -
tsort (18.0)
-
tsort はトポロジカルソートと強連結成分に関するモジュールを提供します。
...ソートと強連結成分に関するモジュールを提供します。
=== Example
//emlist[][ruby]{
require 'tsort'
class Hash
include 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=>[]}.tsor......きます。
//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|
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.mtime f}.max
begin...