What do you do about that fray in the rug, whether it be one the edge or right in the middle? If it is one of those rugs where the threads run and pull out leaving long ugly stripes, you need to act just as soon as you see something loose. The vacuum cleaner or the cat will be playing with it shortly.
Use either clear white glue of the waterproof variety, or contact cement. It is probably best to apply it with a toothpick, slowly poking it all into place where it will dry solidly. Make sure it looks good before you leave it to dry. What you see is what you get.
If you already have that missing thread right across the room, you can "hide" it by cutting away more rug and filling the space with a piece of wood planed down to be smooth and comfortable with the rug. If you choose this "camouflage" technique, it may be necessary to make some more cuts to create a credible pattern of wood fillings. If you don't want wood in the middle of the room, you could cut away the bad rug and then move the rug over tight with the other half, putting in the wood filler along the outside wall. Of course that only works if the rug is not glued down to the floor.