def get_edge_nodes(edge, nodes):
    """Get first and last nodes of an edge.

    Parameters
    ----------
    edge : dict
        the edge information
    nodes : list of dict
        all available nodes

    Returns
    -------
    dict
        information on the first node
    dict
        information on the last node
    """
    first_node = next(node for node in nodes
                      if node["id"] == edge["from"])
    last_node = next(node for node in nodes
                     if node["id"] == edge["to"])
    return first_node, last_node