65件ヒット
[1-65件を表示]
(0.448秒)
種類
- インスタンスメソッド (54)
- ライブラリ (11)
ライブラリ
- tsort (54)
モジュール
- TSort (54)
キーワード
-
each
_ strongly _ connected _ component (11) -
each
_ strongly _ connected _ component _ from (21) - tsort (11)
-
tsort
_ each (11)
検索結果
先頭5件
- TSort
# tsort _ each _ child(node) {|child| . . . } -> () - TSort
# tsort _ each {|node| . . . } -> nil - TSort
# each _ strongly _ connected _ component {|nodes| . . . } -> nil - TSort
# each _ strongly _ connected _ component _ from(node , id _ map={} , stack=[]) -> Enumerator - TSort
# each _ strongly _ connected _ component _ from(node , id _ map={} , stack=[]) {|nodes| . . . } -> ()
-
TSort
# tsort _ each _ child(node) {|child| . . . } -> () (30407.0) -
TSort で拡張されるクラスで定義されていなければならないメソッドです。
...されるクラスで定義されていなければならないメソッドです。
tsort_each_child is used to iterate for child nodes of node.
@param node ノードを指定します。
@raise NotImplementedError TSort で拡張されるクラスで定義されていない場合発生します... -
TSort
# tsort _ each {|node| . . . } -> nil (6212.0) -
TSort#tsort メソッドのイテレータ版です。 obj.tsort_each は obj.tsort.each と似ていますが、 ブロックの評価中に obj が変更された場合は予期しない結果になる ことがあります。
...t_each は obj.tsort.each と似ていますが、
ブロックの評価中に obj が変更された場合は予期しない結果になる
ことがあります。
tsort_each は nil を返します。
閉路が存在するとき、例外 TSort::Cyclic を起こします。
@raise TSort::Cyclic.......
//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, 3], 2=>[3], 3=>[], 4=>[]}
non_sort.tsort_each {|node|
non_sort.tsort_each_child(node){|child|......printf("%d -> %d\n", node, child)
}
}
# 出力
#=> 2 -> 3
#=> 1 -> 2
#=> 1 -> 3
//}
@see TSort.tsort_each... -
TSort
# each _ strongly _ connected _ component {|nodes| . . . } -> nil (6206.0) -
TSort#strongly_connected_components メソッドのイテレータ版です。 obj.each_strongly_connected_component は obj.strongly_connected_components.each に似ていますが、 ブロックの評価中に obj が変更された場合は予期しない結果になる ことがあります。
...ngly_connected_components メソッドのイテレータ版です。
obj.each_strongly_connected_component は
obj.strongly_connected_components.each に似ていますが、
ブロックの評価中に obj が変更された場合は予期しない結果になる
ことがあります。
each_stro......ected_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_conne......cted_component{|nodes|
p nodes
}
#出力
#=> [4]
#=> [2, 3]
#=> [1]
//}
@see TSort.each_strongly_connected_component... -
TSort
# each _ strongly _ connected _ component _ from(node , id _ map={} , stack=[]) -> Enumerator (6206.0) -
node から到達可能な強連結成分についてのイテレータです。
...node から到達可能な強連結成分についてのイテレータです。
返す値は規定されていません。
each_strongly_connected_component_from は
tsort_each_node を呼びません。
@param node ノードを指定します。
//emlist[例 到達可能なノードを表示......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
nodes.each {|node|
non_sort.eac......h_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| . . . } -> () (6206.0) -
node から到達可能な強連結成分についてのイテレータです。
...node から到達可能な強連結成分についてのイテレータです。
返す値は規定されていません。
each_strongly_connected_component_from は
tsort_each_node を呼びません。
@param node ノードを指定します。
//emlist[例 到達可能なノードを表示......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
nodes.each {|node|
non_sort.eac......h_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 (30.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=>[]}.tsort
#=> [3, 2, 1, 4]
{1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}.strongly_connected_co......ents
#=> [[4], [2, 3], [1]]
//}
=== より現実的な例
非常に単純な `make' に似たツールは以下のように実装できます。
//emlist[][ruby]{
require 'tsort'
class Make
def initialize
@dep = {}
@dep.default = []
end
def rule(outputs, inputs=[], &block)
tri......e = [outputs, inputs, block]
outputs.each {|f| @dep[f] = [triple]}
@dep[triple] = inputs
end
def build(target)
each_strongly_connected_component_from(target) {|ns|
if ns.length != 1
fs = ns.delete_if {|n| Array === n}
raise TSort::Cyclic.new("cyclic dependencie...