What is a vertex in a graph?
A vertex is the basic element of a graph that represents an object, point, or entity.
Vertices are nodes that connect to each other via edges.
Example:
- In a road graph, vertices are cities.
- In a social network, vertices are users.
- In a computer network, vertices are devices or servers.
Properties of a vertex:
- Can have an identifier (a number, a name).
- Can hold data (for example, a weight, a label, coordinates).
- Can be connected to other vertices via edges.
Types of vertices:
- Isolated - not connected to any other vertex.
- Adjacent - has at least one edge leading to another vertex.
Summary: a vertex is a "point", and edges are the "lines" that connect these points, forming the structure of a graph.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.