Created
December 10, 2012 12:39
-
-
Save tabris2012/4250327 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def makeScoreEdges(posterSearch, gviz, nodes, depth) #指定ノード数だけグラフ描画 | |
#posterHash = @posterDistance[posterSearch].sort{|a, b| b[1][1] <=> a[1][1]} #スコアの高い順に並び替え | |
if !(posterHash = @posterDistance[posterSearch]) | |
return | |
end | |
posterHash = posterHash.slice(0, nodes) | |
nextDepth = depth - 1 | |
if posterHash.last[1][1] / posterHash[0][1][1] > 0.7 #設定値より大きければ出力数変更 | |
nodes = @nodes - @depth + depth -1 | |
else #探索深度をさらに減らす | |
nextDepth -= 1 | |
end | |
posterHash.each do |number, score| | |
gviz.route :"p#{posterSearch[0].gsub(/\-/, "")}" => :"p#{number[0].gsub(/\-/, "")}" | |
if nextDepth >1 and nodes >0 | |
makeScoreEdges(number, gviz, nodes, nextDepth) | |
end | |
#深さ探索前のエッジにラベルをつける | |
if depth == @depth | |
gviz.edge :"p#{posterSearch[0].gsub(/\-/, "")}_p#{number[0].gsub(/\-/, "")}", headlabel:"#{score[0]}", fontsize:30, fontcolor:"red" | |
end | |
end | |
#まとめて書式設定 | |
posterHash.each do |number, score| | |
gviz.node :"p#{number[0].gsub(/\-/, "")}", label:"#{number[0]}:#{number[1]}", fontsize:@fonts[depth -1], color:depth | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment