counting dirty nodes and edges