Add helper for building weighted graph for rank