Black Lives Matter. Please consider donating to Black Girls Code today.

Plotting multiple lines with distinct colors and widths

I have a Graph with a lot of edges and nodes. I want to plot the edges width proportional to some weight array.
I found a code for doing this and the output returns very quick. But it ony shows all edges with the same width.

the graph object looks like this:

edge_trace = go.Scatter ( x = edge_x, y=edge_y, line = dict(width = 0.8, color="#fff"), hoverinfo = "none", mode = "lines)
node_trace = 
        x=node_x, y=node_y,
        mode='markers',
        text = " ",
        textposition ="middle left",
        hoverinfo='text',
        marker=dict(
            showscale=False,
            colorscale='RdBu',
            reversescale=True,
            color=[],
            size=12,
            colorbar=dict(
                thickness=15,
                title='Node Connections',
                xanchor='left',
                titleside='right'
            ),
            line_width=2))

and thefigure object looks like

fig = go.Figure(data = [edge_trace,node_trace], layout = .....)

this doesn’t draw the weighted edges. So I add a loop selecting a weight from weight array, a proportional width named width_ and do this:

fig.add_trace(go.Scatter(x=X,y=Y), line = dict(width = width_, color = color_) )

but it draws above the previus graph and makes it slow.

Is there any solution? How can I pass a width array to edge_trace ?

Also I would like that the name of every edge shows to the left, now it only shows passing the mouse above them with a box as image

here a little example