Created
August 30, 2014 16:56
-
-
Save shirayuca/bbf0b769a1621fa13825 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
# ランダムグラフを描画し、平均経路長を算出します。 | |
# p=0.1, 0.3 と変化させ、作図と平均経路長を算出してみましょう | |
library(igraph) | |
graph3 <- random.graph.game(50, p=0.05) #頂点は50、線を引く確率は0.05 | |
plot(graph3) | |
dev.off() | |
average.path.length(graph3) | |
# 第2引数に unconnected = FALSE を加えると、 | |
# 距離無限大の成分がグラフに含まれる頂点数の値に置き換えられ算出される |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment