title: Efficiently performance Graph Contraction based on a criteria
body: <p>I have a directed weighted simple graph. I want to contract every node that has equal node value with another node that is directly connected to it. After contraction parallel edges would be made into one with the sum of the weights.  </p>
  
  <p>What is the most efficient way/algorithm for doing this? My graph is stored as an adjacency list if that would alter the answer.</p>