Only add nodes that are actually connected.