graphs.markov_chain =================== .. py:module:: graphs.markov_chain Classes ------- .. autoapisummary:: graphs.markov_chain.MarkovChainGraphUndirectedUnweighted Functions --------- .. autoapisummary:: graphs.markov_chain.get_transitions Module Contents --------------- .. py:class:: MarkovChainGraphUndirectedUnweighted Undirected Unweighted Graph for running Markov Chain Algorithm .. py:method:: add_node(node: str) -> None .. py:method:: add_transition_probability(node1: str, node2: str, probability: float) -> None .. py:method:: get_nodes() -> list[str] .. py:method:: transition(node: str) -> str .. py:attribute:: connections .. py:function:: get_transitions(start: str, transitions: list[tuple[str, str, float]], steps: int) -> dict[str, int] Running Markov Chain algorithm and calculating the number of times each node is visited >>> transitions = [ ... ('a', 'a', 0.9), ... ('a', 'b', 0.075), ... ('a', 'c', 0.025), ... ('b', 'a', 0.15), ... ('b', 'b', 0.8), ... ('b', 'c', 0.05), ... ('c', 'a', 0.25), ... ('c', 'b', 0.25), ... ('c', 'c', 0.5) ... ] >>> result = get_transitions('a', transitions, 5000) >>> result['a'] > result['b'] > result['c'] True