Common mathematical theories can have profound applications in understanding real materials. The intrinsic connection between aperiodic orders observed in the Fibonacci sequence, Penrose tiling, and quasicrystals is a well-known example. Another example is the self-similarity in fractals and dendrites. From transmission electron microscopy experiments, we found that FexTaS2 crystals with x = 1/4 and 1/3 exhibit complicated antiphase and chiral domain structures related to ordering of intercalated Fe ions with 2a × 2a and √3a × √3a superstructures, respectively. These complex domain patterns are found to be deeply related with the four color theorem, stating that four colors are sufficient to identify the countries on a planar map with proper coloring and its variations for two-step proper coloring. Furthermore, the domain topology is closely relevant to their magnetic properties. Our discovery unveils the importance of understanding the global topology of domain configurations in functional materials.