種類
- インスタンスメソッド (96)
- ライブラリ (11)
ライブラリ
- tsort (96)
モジュール
- TSort (96)
キーワード
-
each
_ strongly _ connected _ component (21) -
each
_ strongly _ connected _ component _ from (21) -
strongly
_ connected _ components (11) - tsort (22)
-
tsort
_ each (21)
検索結果
先頭5件
- TSort
# tsort _ each _ node {|node| . . . } -> () - 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 -> Enumerator - TSort
# each _ strongly _ connected _ component {|nodes| . . . } -> nil
-
TSort
# tsort _ each _ node {|node| . . . } -> () (18207.0) -
TSort で拡張されるクラスで定義されていなければならないメソッドです。
...TSort で拡張されるクラスで定義されていなければならないメソッドです。
tsort_each_node is used to iterate for all nodes over a graph.
@raise NotImplementedError TSort で拡張されるクラスで定義されていない場合発生します。... -
TSort
# each _ strongly _ connected _ component _ from(node , id _ map={} , stack=[]) -> Enumerator (112.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, &bloc......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| . . . } -> () (112.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, &bloc......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 -> Enumerator (106.0) -
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
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... -
TSort
# each _ strongly _ connected _ component {|nodes| . . . } -> nil (106.0) -
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
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... -
TSort
# strongly _ connected _ components -> Array (106.0) -
強連結成分の集まりを配列の配列として返します。 この配列は子から親に向かってソートされています。 各要素は強連結成分を表す配列です。
...ます。
各要素は強連結成分を表す配列です。
//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=>[]}
p non_sor... -
TSort
# tsort -> Array (106.0) -
頂点をトポロジカルソートして得られる配列を返します。 この配列は子から親に向かってソートされています。 すなわち、最初の要素は子を持たず、最後の要素は親を持ちません。
...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
sorted = {1=>[2, 3], 2=>[3], 3=>[], 4=>[]}.tsort
p sort... -
TSort
# tsort _ each -> Enumerator (106.0) -
TSort#tsort メソッドのイテレータ版です。 obj.tsort_each は obj.tsort.each と似ていますが、 ブロックの評価中に obj が変更された場合は予期しない結果になる ことがあります。
...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
# tsort _ each {|node| . . . } -> nil (106.0) -
TSort#tsort メソッドのイテレータ版です。 obj.tsort_each は obj.tsort.each と似ていますが、 ブロックの評価中に obj が変更された場合は予期しない結果になる ことがあります。
...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 (12.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]......分に関するアルゴリズムを使っているからです。
とはいえ 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....