Types of Graphs
Explore the two main types of graphs, undirected and directed, and understand how edge directions affect graph structure. Learn to calculate possible edges for each graph type and grasp their practical use cases in programming with C#.
We'll cover the following...
Types of graphs
There are two common types of graphs:
- Undirected
- Directed
Undirected graph
In an undirected graph, the edges are by default, bidirectional by default. For a pair (2, 3), there exists an edge between vertex 2 and 3 without any specific direction. You can go from vertex 2 to 3 or vice versa (from 3 to 2).
Calculate the maximum possible edges for an undirected graph. You are denoting an edge between vertex a and b as (a, b). So, the maximum possible edges of a graph with n vertices will be all possible pairs of vertices of that graph, assuming that there are no self loops.
If a graph has n vertices, then there are C(n,2) possible pairs of vertices according to combinatorics. Solving C(n,2) by binomial coefficients ...