def find_path(entityset, source_entity, target_entity):
    'Find a path of the source entity to the target_entity.'
    nodes_pipe = [target_entity]
    parent_dict = {target_entity: None}
    while len(nodes_pipe):
        parent_node = nodes_pipe.pop()
        if (parent_node == source_entity):
            break
        child_nodes = ([e[0] for e in entityset.get_backward_entities(parent_node)] + [e[0] for e in entityset.get_forward_entities(parent_node)])
        for child in child_nodes:
            if (child not in parent_dict):
                parent_dict[child] = parent_node
                nodes_pipe.append(child)
    node = source_entity
    paths = [[node]]
    while (node != target_entity):
        node = parent_dict[node]
        paths.append((paths[(- 1)] + [node]))
    return paths
Find a path of the source entity to the target_entity.
def find_path(entityset, source_entity, target_entity):
    
    nodes_pipe = [target_entity]
    parent_dict = {target_entity: None}
    while len(nodes_pipe):
        parent_node = nodes_pipe.pop()
        if (parent_node == source_entity):
            break
        child_nodes = ([e[0] for e in entityset.get_backward_entities(parent_node)] + [e[0] for e in entityset.get_forward_entities(parent_node)])
        for child in child_nodes:
            if (child not in parent_dict):
                parent_dict[child] = parent_node
                nodes_pipe.append(child)
    node = source_entity
    paths = [[node]]
    while (node != target_entity):
        node = parent_dict[node]
        paths.append((paths[(- 1)] + [node]))
    return paths