adding weighted graph of words