With the increasing interdependence between the power system and the natural gas system, the optimization operation of the electric-gas integrated energy system has become a current research hotspot. However, the non-convexity and nonlinearity of power and gas system bring huge challenge for the optimization solution, many research works ignore the complicated network constraints. Thus, this paper develops the optimization model of the electric-gas system, considering complicate AC power flow constraints and steady state gas flow constraints, and adopted particle swarm optimization (PSO) algorithm. In order to consider the complicated constraints of power and gas networks, the output of non-slack units and gas production of non-slack wells are obtained according to the position of particles, and the distribution of energy flow is obtained by the energy flow calculation method of the electric-gas integrated energy system based on the cycle iteration. Based on the distribution of energy flow, the network constraints is introduced to the objective function as a penalty item with a big enough coefficient. In the simulation analysis, the test system integrated by 13-bus power network and the 7-node gas network is adopted to verify the effectiveness of the method.