'Find the nodes of the graph which are only 1 rank apart from each other'

def reachable_node(self, node):

    if (node not in self.reachable_nodes):
        self.reachable_nodes.append(node)
    for edge in self.edge_wt:
        if (edge[0] == node):
            if (self.edge_wt[edge] == 1):
                self.tree_edges.append(edge)
                if (edge[1] not in self.reachable_nodes):
                    self.reachable_nodes.append(edge[1])
                self.reachable_node(edge[1])
