4
4
5
5
6
6
class MarkovChainGraphUndirectedUnweighted :
7
- '''
7
+ """
8
8
Undirected Unweighted Graph for running Markov Chain Algorithm
9
- '''
9
+ """
10
10
11
11
def __init__ (self ):
12
12
self .connections = {}
13
13
14
14
def add_node (self , node : str ) -> None :
15
15
self .connections [node ] = {}
16
16
17
- def add_transition_probability (self , node1 : str ,
18
- node2 : str ,
19
- probability : float ) -> None :
17
+ def add_transition_probability (
18
+ self , node1 : str , node2 : str , probability : float
19
+ ) -> None :
20
20
if node1 not in self .connections :
21
21
self .add_node (node1 )
22
22
if node2 not in self .connections :
@@ -36,10 +36,10 @@ def transition(self, node: str) -> str:
36
36
return dest
37
37
38
38
39
- def get_transitions (start : str ,
40
- transitions : List [Tuple [str , str , float ]],
41
- steps : int ) -> Dict [str , int ]:
42
- '''
39
+ def get_transitions (
40
+ start : str , transitions : List [Tuple [str , str , float ]], steps : int
41
+ ) -> Dict [str , int ]:
42
+ """
43
43
Running Markov Chain algorithm and calculating the number of times each node is
44
44
visited
45
45
@@ -59,7 +59,7 @@ def get_transitions(start: str,
59
59
60
60
>>> result['a'] > result['b'] > result['c']
61
61
True
62
- '''
62
+ """
63
63
64
64
graph = MarkovChainGraphUndirectedUnweighted ()
65
65
0 commit comments