Vehicle-to-grid (V2G) is a system where electric vehicles connect to the power grid to charge their batteries when there is extra electricity. Later, when the grid needs more power, the vehicles can send stored energy back to the grid. This process helps balance the supply and demand of electricity. The flow starts with the EV connecting to the grid, charging when there is excess power, storing energy, and then sending energy back when the grid requests it. Variables like battery charge level and grid demand change during this process. Key points include charging only during excess power times, sending energy back only if the battery has energy and the grid needs it, and stopping charging when the battery is full. This system helps make electricity use more efficient and supports grid stability.