A star graph has one center vertex connected to all other vertices. The center has degree n−1, and all other vertices have degree 1.
You could build an adjacency list and count degrees for each vertex. Check if one vertex has degree n−1 and all others have degree 1. This works but requires storing the graph.
There is a smarter approach using edge counting. I'll show you the trick in the next unit.