Added support for weights and changed to directed