implementation of a weighted directed graph (digraph)