def build_tree_from_chains(chains, inform7):
    G = nx.DiGraph()
    root = 'root'
    labels = {}
    for chain in chains:
        commands = ([root] + inform7.gen_commands_from_actions(chain.actions))
        G.add_nodes_from(commands)
        G.add_edges_from(zip(commands[:(- 1)], commands[1:]))
        labels.update(dict(zip(commands, commands)))
    return (G, labels)
def build_tree_from_chains(chains, inform7):
    G = nx.DiGraph()
    root = 'root'
    labels = {}
    for chain in chains:
        commands = ([root] + inform7.gen_commands_from_actions(chain.actions))
        G.add_nodes_from(commands)
        G.add_edges_from(zip(commands[:(- 1)], commands[1:]))
        labels.update(dict(zip(commands, commands)))
    return (G, labels)