De-duplicate dependency/graph building functions