How do the boundaries of a galaxy differ from the boundaries of the cosmos?

Answer

A galaxy has definite boundaries defined by gravity while the cosmos has no edge

Galaxies are large-scale systems defined by the gravitational attraction of their constituents, which gives them definite, albeit sprawling, boundaries. In contrast, the cosmos—being the totality of all space, time, matter, and energy—does not have an edge in any conventional sense, as it encompasses all that exists.

How do the boundaries of a galaxy differ from the boundaries of the cosmos?
galaxyastronomyuniversecosmos