def edgecolor_by_source(G, node_colors):
    """ Returns a list of colors to set as edge colors based on the source node for each edge.

    Parameters 
    ----------

    G : graph.
        A networkx graph.

    node_colors : list 
        List of node colors.

    Example  
    --------

    >>> colormap = {'male':'b','female':'r'}
    >>> node_colors = set_node_color(G,"gender",colormap)
    >>> edge_colors = edgecolor_by_source(G,node_colors)

    Returns
    -------
    list
        list of colors for each edge of the graph color set by the source node.

    """

    edge_colormap = []
    node_colormap = dict(zip(G.nodes(), node_colors))
    for edge in G.edges():
        edge_colormap.append(node_colormap[edge[0]])
    return edge_colormap