Skip to content

Commit

Permalink
add random walk abstract class
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyasvinaya committed Sep 29, 2024
1 parent 5e62bdf commit 23fe4a8
Showing 1 changed file with 55 additions and 7 deletions.
62 changes: 55 additions & 7 deletions qtsit/algorithms/randomwalk.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,61 @@
Code for random walk algorithms.
"""

import random

def algorithm1(args: int) -> int:
"""Summary

Parameters
----------
args : _type_
_description_
# abstract class walk - will be used in classical walk and quantum walk
class walk:
"""Abstract class for random walk algorithms.
"""
return args

def __init__(self, graph):
self.graph = graph
self.current_node = random.choice(graph.nodes())
self.visited = [self.current_node]
self.steps = 0

def walk(self, steps):
for i in range(steps):
self.step()

def step(self):
self.steps += 1
self.current_node = self.next_node()
self.visited.append(self.current_node)

def next_node(self):
pass

def get_visited(self):
return


class classical_walk(walk):
"""Classical random walk algorithm.
"""

def __init__(self, graph):
super().__init__(graph)

def next_node(self):
return random.choice(list(self.graph.neighbors(self.current_node)))


class quantum_walk(walk):
"""Quantum random walk algorithm.
"""

def __init__(self, graph):
super().__init__(graph)

def next_node(self):
return random.choice(list(self.graph.neighbors(self.current_node)))


class groundtruth:
"""Groundtruth class for the random walk algorithms.
"""

def __init__(self) -> None:
pass

0 comments on commit 23fe4a8

Please sign in to comment.