Test code using weighted graphs