Given a List of Dictionaries with source, target, and weight attributes, return a weighted, directed graph.

def from_edges(edges, source_key='source', target_key='target', weight_key='weight', directed=True):
    """
    Given a List of Dictionaries with source, target, and weight attributes, return a weighted, directed graph.
    """
    raw = list(map(lambda x: [x[source_key], x[target_key], int(x[weight_key])], edges))
    g = IGraph.TupleList(raw, weights=True, directed=directed)
    g.vs['indegree'] = g.degree(mode="in")
    g.vs['outdegree'] = g.degree(mode="out")
    g.vs['label'] = g.vs['name']
    if 'group' not in g.vs.attributes():
        g.vs['group'] = labels_to_groups(g.vs['label'])
    return g