You are correct, it should take in a datum and an optional index. Is there an existing class that represents a js object { source : x, target: y }?