Fix memory usage issue caused by adding same node multiple times

This issue happens when multiple nodes share same target node, and
will consume lots of memory and slow down the layout calculation
greatly when a graph being rendered is close to a complete bipartite
graph at each step of the flow.
Merge remote-tracking branch 'hongtaobai/master'