• API
• FAQ
• Tools
• Archive
A Pastebin account makes a great Christmas gift
SHARE
TWEET

# Untitled

a guest Nov 14th, 2017 58 Never
ENDING IN00days00hours00mins00secs

1. def random_walk(adj_matrix, steps=100, baised=False, alpha=1.0):
2.
3.     #D_I, D_J, D_K ----- D OF EVERYTHING-------- (DONE)
4.
5.     d_term=[]
6.
8.
10.
11.         d_term.append(current)
12.
13.     d_sum=sum(d_term)
14.
15.     #-----------Create C_I TERM FOR BAISED----------
16.     c_i_term=[]
17.     c_i_term_list=[]
18.
20.
22.
24.
25.             c_i_term.append(current_term)
26.
27.         #adding the sum of c_i to the list
28.         c_i_term_list.append(sum(c_i_term))
29.
30.         #clear list
31.         c_i_term[:]=[]
32.
33.     #---------------DENOMENATOR for T_i_J ----------
34.     current_term=[]
35.     current_term_list=[]
36.     denomenator_list=[]
37.
39.
41.
43.
44.             current_term_list.append(current_term)
45.
46.         denomenator_list.append(sum(current_term_list))
47.
48.
49.     #--------DENOMINATOR for P_I (BAISED)---------
50.     denomenator_term=[]
51.
53.
54.         #denomenator for p_i
56.
57.         denomenator_term.append(d)
58.
59.
60.     #------CREATING P_I LISTS -----------#
61.
62.     if baised==False:
63.
64.         # make p_i_list
65.         p_i_list=[]
66.
68.
70.
71.             p_i_list.append(p_i)
72.
73.     else:
74.
75.         #creating list of p_i terms
76.         p_i_list=[]
77.
79.
81.
82.             p_i_list.append(p_i)
83.
84.     #CREATING TRANSITION MATRIX ( DONE - BAISED==FALSE)
85.     trans_matrix = [ [0 for i in range(len(adj_matrix))] for j in range(len(adj_matrix)) ]
86.
87.
89.
91.
92.             #if baised=true
93.             if baised==False:
94.
96.
97.             else:
98.
100.
101.
102.     #setting up walk list with starting term
103.
104.     current_vertex=choose_vertex(p_i_list)
105.
106.     walk=[current_vertex]
107.
108.     #adding to walk by iterating through the transition matrix
109.     for i in range(0, steps):
110.
112.
113.         walk.append(new_vertex)
114.
115.         current_vertex=new_vertex
116.
117.
118.     print walk
119.
120.
121. random_walk(get_graph_from_series(), steps=200, baised=False, alpha=1)
122. print''
123.
124. print''
125. random_walk(get_graph_from_series(), steps=200, baised=True, alpha=5.0)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top