Cluster structure and dynamics in gels and glasses