She must have realized she had cancer.

Literal

She [topic-は] cancer [in-に] is-suffering [thing-of-こと-を] learned [must-be-に違いない].

Three structural pieces stacked together. ~にかかる ('catch, suffer from') is the standard verb for falling ill — taking に for the disease ('be hit by X'); the ~ている form gives the resultative state of being ill. The clause がんにかかっていること is a nominalized embedded clause ('the fact that she has cancer') functioning as the object of 知った. ~に違いない ('must be, surely') is the speaker's confident inference based on evidence — stronger than ~だろう, closer to English 'must have.'