The wide promotion of electric heating has necessitated the combined analysis of the electric power system (EPS) and the district heating network (DHN) for economic and secure improvement. However, the flexibility of DHN brought by thermal dynamics is governed by partial differential equations (PDE), which is difficult to be accurately quantified. The traditional numerical methods usually solve the problem based on discretization, but the extra complexity and numerical oscillation inevitably occur. To address the problem, this paper proposes a fully analytical method (FAM) to describe the thermal dynamics based on a bilateral characteristic line method (CLM), avoiding inaccurate state estimation and operational strategy design. A FAM-based equivalent model is then developed to quantify the relationship between thermal sources and demands and reduce model complexity. Finally, the expression of average temperature is derived to reformulate the optimal energy flow (OEF) problem in the heat and electricity integrated energy system (HE-IES), which accurately reflects the influence of thermal dynamics in a continuous-time domain. Case studies indicate that the proposed FAM significantly improves the analysis accuracy, stability, and efficiency over the traditional numerical methods in simulation and optimization.