Topology of writhing