added support for weighted vertices