A graph is a set of vertices and edges that form connections between the vertices. In a more formal approach, a graph G is an ordered pair of a set V of vertices and a set E of edges, given as G = (V, E) in formal mathematical notation.
An example of a graph is given here:
Let's discuss some of the important definitions of a graph:
- Node or vertex: A point or node in a graph is called a vertex, which is usually represented in a graph by a dot. In the preceding diagram, the vertices or nodes are A, B, C, D, and E.
- Edge: This is a connection between two vertices. The line connecting A and B is an example of an edge in the preceding graph.
- Loop: When an edge from a node is incident on itself, that edge forms a loop.
- Degree of a vertex: The total number of edges that are incident on a given vertex is called the degree of that vertex. For example, the degree of the B vertex...