Sometimes you find situations in which some user action results in loading a new dataset for your force-directed graph. This update action may result either in the display of a completely new force-directed graph or a subset of such graph. To address this need, this is my approach using the enter-update-exit pattern for the force-directed graph in D3.v4.
It seems to work pretty decently, but if you find any bugs or suggestions, please feel free to tell me.
https://d3js.org/d3.v4.min.js