def transform(gr, transform, vertex_or_edge='vertex'):
    """transformes values and creates new for a graph

    :param transform: iterable of dict. Each tripel contains "name" name of vertex attribute to be transformed,
    "func" a callable which can be called with the values of "name". "default" a value which should be used if the
    function call doesn't work. (e.g. {"name" : year, "func" : int, "default": 0})
    """
    assert vertex_or_edge in ['vertex', 'edge'
        ], "vertex_or_edge has to be either 'vertex' or 'edge'"
    for t in transform:
        new_val = []
        if vertex_or_edge == 'vertex':
            iterate = gr.vs[t['name']]
        else:
            iterate = gr.es[t['name']]
        for val in gr.vs[t['name']]:
            try:
                new_val.append(t['func'](val))
            except TypeError:
                new_val.append(t['default'])
            except ValueError:
                new_val.append(t['default'])
        gr.vs[t['name']] = new_val
