HPO機密日誌

自己をならふといふは、自己をわするるなり。

昨日の続き

....いんやぁ、大変なことにチャレンジしちまったのかも...

#include "test.idx"

#console

'スケールフリーネットワークシュミレータ
'作成 平成16年10月23日 ひでき

'初期設定
dim nord[20,20] as integer ' ノードのリンク配列 最大ノード 1〜20。[n,m]の値1=リンク、0=なし、n→m
dim nord_n as integer ' 存在するノードの数
dim link_n as integer ' 存在するリンクの数の合計
dim link_colum_n[20],link_law_n[20] as integer ' ノードの持つリンクの数を示す。
dim i,j,k as integer ' 制御用変数
dim sel_proc as string '処理の選択
dim n_of_link,temp_rand as single 'ノードにいくつリンクを発生させるか?
dim link_to as single 'リンク生成時のnord[link_to,j]となるようにする。
dim temp_nord_n as integer 'サブルーティン内のnord_n
dim rescue_n as integer '無限ループ回避用

'メイン

Randomize
initialize_nord()
sum_link()

do

input "処理は?(終了=E、次処理=null、印刷=P...)";sel_proc

select case sel_proc
case "E"
exit do
case "P"
sum_link()
nord_print()
case else
add_nord()
sum_link()
nord_print()
end select
loop until (sel_proc="E")

' サブルーチン ノード配列の初期化
sub initialize_nord()

nord_n=0

for i=1 to 20
for j=1 to 20
nord[i,j]=0
next
next
end sub

'ノードを付け加える
sub add_nord()
nord_n=nord_n+1
nord[nord_n,nord_n]=1
link_n=link_n+1
add_link()
end sub

'リンクを発生させる
sub add_link() ' 新しく加わったnord[nord_n,?]にリンクを指定数(n_of_lin)加える
temp_nord_n=nord_n

'n_of_link=temp_nord_n-1

n_of_link=1

while n_of_link >0
rescue_n=1
do

j=1

do
temp_rand=rand()/32767
loop until (0