d********w 发帖数: 363 | 1 给出有向图的边
edges = [(1,2),(2,3),(3,1),(2,1),(3,2),(1,3)]
# example
# move particle along graph by choosing random neighbors like so:
# start at 1
# step 1: 1 -- > 3
# step 2: 3 --> 2
# step 3: 2 --> 1
# etc.
给定迭代次数,打印出随机访问的neighbor
上面输出
1->3->2->1.... ->2
random_walk(int iteration) |
|