def transform_vertex(u, phi):
    """
        Given a vertex id u and a set of partial isomorphisms phi.
        Returns the transformed vertex id
    """
    for _phi in phi:
        if _phi[0] == u:
            return _phi[1]
    raise Exception('u couldn\' be found in the isomorphisms')