This simple diagram below will give you a better understanding of what this circuit is accomplishing. The dimmer switch will have stranded wires that must be sliced to the solid cable wiring in a pigtail fashion. A rheostat or dimmer makes it possible to vary the current flowing to a light fixture thereby varying the intensity of the light.
The common terminal of the 3-way switch connects to the light fixtures.
The 3-way dimmer and 3-way switch are also interchangeable. Standard for connection fans with 4 wires was developed by intel. The dimmer switch has 2 black wires and one red. Three-wire cable runs between the switches and 2-wire cable runs to the light.