I applied an unweighted random walk function to a graph that I built in Python using NetworkX. Below is a snippet of my random walk program. Elsewhere in my program, I have a method that creates a graph, and I have a method that mimics the various custom graph testing methods that I wrote. One of these graph testing methods selects two nodes randomly from the graph and randomly wanders between them. Two things that are computed from this random walk reach time (the number of links that intersect from start to end point) and switching time (number of lines traveled from start to end and back to start point).
def unweighted_random_walk(starting_point,ending_point, graph): ''' starting_point: String that represents the starting point in the graph ending_point: String that represents the ending point in the graph graph: A NetworkX Graph object '''
My random walk code is pretty straight forward because I just select random nodes before reaching the endpoint. However, this current implementation is very slow when I try to run some random walks (I think I need to run a million at some point).
My question is: is there a way to use Hadoop MapReduce to parallelize some of the operations that occur here for this random walk? Is there a better way to make my casual walk?
source share