is a function because we need to run two passes due to flatgraph-specific implementation details: one to add the nodes, and one to add edges and set node properties