benedekrozemberczki/Splitter

an error in walker maybe?

Nitinsiwach opened this issue · 2 comments

I dont know much about this work in details. however, while implementing i am running into sample larger than population. I think in src/walker.py it should be

def small_walk(self, start_node):
        """
        Doing a truncated random walk.
        :param start_node: Start node for random walk.
        :return walk: Truncated random walk with fixed maximal length.
        """
        walk = [start_node]
        while len(walk) < self.args.walk_length:
            if len(nx.neighbors(self.graph,walk[-1])) ==0:
                break
            walk = walk + [random.sample(nx.neighbors(self.graph,walk[-1]),1)[0]]
        return walk

Instead of

def small_walk(self, start_node):
        """
        Doing a truncated random walk.
        :param start_node: Start node for random walk.
        :return walk: Truncated random walk with fixed maximal length.
        """
        walk = [start_node]
        while len(walk) < self.args.walk_length:
            walk = walk + [random.sample(nx.neighbors(self.graph,walk[-1]),1)[0]]
            if len(nx.neighbors(self.graph,walk[-1])) ==0:
                break
        return walk

Corrected.