Graphs
Imagine a social network with 6 subscribers (A, B, C, D, E and F) where:
- A is friends with B, C and D
- B is friends with A and D
- C is friends with A, E and D
- D is friends with all other subscribers
- E is friends with C, D and F
- F is friends with E and D
The description of this social network, despite its small number of subscribers, is already somewhat tedious, so imagine this same description with a social network having millions of subscribers!
There is a more "visual" way to represent this social network: we can represent each subscriber by a circle (with the subscriber's name located in the circle) and each relationship "X is friends with Y" by a line segment connecting X and Y ("X is friends with Y" and "Y is friends with X" being represented by the same line segment).
Here's what it gives with the social network described above:
This kind of figure is called a graph. Graphs are mathematical objects widely used, especially in computer science. The circles are called vertices and the line segments edges.
Definitions applicable to graphs
Graphs have properties that must be known, understood, and their calculations mastered. These properties will be regularly used in computer science.
Let G be a graph.
Application of definitions
In the graph above, the distance between vertex A and vertex F equals 2 (path A-D-F).
WARNING: we're talking about the minimum number of edges, A-D-E-F is also a path between A and F but in this case, we have 3 edges.
Still in the graph above:
- distance (A-B) = 1;
- distance (A-C) = 1;
- distance (A-D) = 1;
- distance (A-E) = 2;
- distance (A-F) = 2;
We can therefore say that the maximum distance existing between vertex A and the other vertices of the graph is 2 (distance (A-E) and distance (A-F)). We can therefore say that the eccentricity of A is 2.
Another example:
- distance (D-A) = 1;
- distance (D-B) = 1;
- distance (D-C) = 1;
- distance (D-E) = 1;
- distance (D-F) = 1;
We can therefore say that the eccentricity of D is 1.
In the graph above all vertices have an eccentricity of 2 except vertex D which has an eccentricity of 1, we can therefore affirm that the center of the graph is vertex D.
In the graph above the maximum distance between 2 vertices is 2, we can therefore say that the diameter of the graph is 2.
D has an eccentricity of 1, it is the center of graph 1, we can therefore say that the radius of the graph above is 1.