You would simply have to apply the vertex group to the points first with
Capture Attribute, and then use that as the selection for
Mesh to Curve:
Here I use the node
Named Attribute (Blender 3.2) for the vertex group, but of course you can also do this with a Group Input (Blender 3.0).
A short (simplified) explanation:
It has to do with "Domains".
A vertex group defines points, but
Mesh to Curve works based on edges.
When you process a vertex group in Geometry Nodes, this selection is interpolated to all other domains, which also selects adjacent edges.
So all edges that have a point in this vertex group will be converted by the node
Mesh to Curve.
Capture Attribute, however, the selection is explicitly applied only to the points domain and then only edges are selected that actually have both points in this vertex group.