Statistical mechanics with topological constraints: I | Synapse