The IGraph/M package makes such styling tasks fairly easy. Suppose you have the following adjacency matrix, containing weights:
wam = {{0, 10, 10, 0, 0, 0, 8, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 5, 18, 0,
0}, {5, 0, 0, 20, 0, 0, 0, 20, 0, 0}, {0, 0, 0, 0, 0, 0, 13, 0, 0,
0}, {0, 0, 8, 0, 0, 11, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0,
0}, {0, 0, 0, 19, 0, 0, 0, 17, 0, 0}, {0, 6, 0, 0, 0, 17, 0, 0, 0,
0}, {0, 0, 0, 18, 19, 17, 0, 0, 0, 18}, {0, 0, 0, 0, 20, 0, 0, 0,
0, 0}};
First we make a graph out of it:
g = IGWeightedAdjacencyGraph[wam, EdgeStyle -> Thick];
Then we style:
Legended[
IGEdgeMap[ColorData["Rainbow"], EdgeStyle -> Rescale@*IGEdgeProp[EdgeWeight], g],
BarLegend[{"Rainbow", MinMax@IGEdgeProp[EdgeWeight][g]}]
]