The invention discloses a pen interaction-based primitive topological composition method, which relates to the field of computer interaction and comprises the following steps of: drawing a sketch on a touch screen by using a touch pen; selecting the drawn sketch, calling a
sketch recognition engine based on a YOLOv5 neural network for recognition, recognizing standard primitive information and irrelevant writing information, wherein the standard primitive information comprises primitive category and position information; removing sketch
stroke information corresponding to the standard primitive from
stroke data of the sketch, and identifying the remaining sketch strokes as line segments; judging a primitive connection relation according to the identified primitive category, primitive position,
line segment and position relation between the
line segment and the primitive so as to establish a graph structure expression; according to the graph structure representation, the primitive category and the
line segment, converting into a normalized topological structure graph, and displaying on the original drawing position of the touch screen; and storing the topological
structure diagram, and editing the standard primitives and the topological
structure diagram as required.