Graphs in Data Structures and Algorithms

Business entities handle a large volume of data. Data must be organized for storage. The concept of Data Structures and Algorithms is pitched in for this purpose. A data structure is employed for purposes beyond merely organizing data. It is used for data processing, retrieval, and archiving as well. Numerous fundamental and sophisticated types of data structures are used by almost all software systems and programmes that have been developed. We must therefore be knowledgeable about data structures.

Advertisements

 

Graphs

 

A graph is a collection of vertices (V1, V2,…Vn) and edges (E = E1, E2,….En). Here, the unordered pair of vertices can be used to identify each individual edge (Vi, Vj). If there is an edge whose endpoints are Vi and Vj, then the two vertices Vi and Vj are said to be adjacent. As a result, Vi and Vj are said to link at E.

The following terminologies are used in Graphs:

  1. i) Order of the Graph = The number of vertices in the graph
  2. ii) Size of the Graph = The number of edges in the graph

iii) Degree of a Vertex of a Graph = Number of edges incident to the vertex

 

Different Types of Graphs

 

Null Graph

A null graph is a graph that has no edges.

Trivial Graph

A single vertex graph is known as Trivial Graph.

Non-Directed Graph

Although there are edges in a non-directed graph, they are not directed edges.

Directed Graph

Each edge in a directed graph has a direction.

Simple Graph

A simple graph is one that has no loops and no parallel edges.

Connected Graph

If a path connects every pair of vertices in a graph G, then the graph is said to be linked. Every vertex in the graph must have at least one edge. In order to claim that it is connected to another vertex located on the opposite side of the edge.

Disconnected Graph

If a graph G does not have at least two linked vertices, it is said to be disconnected.

Regular Graph

If all of a graph G’s vertices have the same degree, the graph is said to be regular. A graph is referred to as a “k-regular graph” if each vertex’s degree equals k.

Complete Graph

A full graph is a straightforward graph with ‘n’ mutual vertices, and it is represented by the symbol ‘Kn’. A complete graph is one in which every vertex has at least one edge with every other vertex. In other terms, a graph is said to be complete if each vertex is connected to every other vertex.

Cyclic Graph

A simple graph is referred to as a cycle graph if all of its edges form a cycle with length n, (n >= 3). A graph is referred to as a cycle graph if each vertex has a degree of two.

Wheel Graph

A new vertex is added to a cycle graph Cn-1 to create a wheel graph. This new vertex, known as a Hub, is connected to every other vertex in Cn.

Acyclic Graph

A graph which is not connected to each other is called an Acyclic Graph.

Bi-Partite Graph

If every edge of E connects a vertex in V1 to a vertex in V2, then G = (V, E) with vertex partition V = “V1, V2” is referred to as a bipartite graph. A Bipartite graph typically consists of two sets of vertices, let’s call them V1 and V2, and if an edge is constructed, it should link any vertex in set V1 to any vertex in set V2.

Complete Bi-Partite Graph

When every vertex in partition V = “V1, V2” of a bipartite graph “G,” G = (V, E), is linked to every vertex in partition V2, the graph is said to be complete. Each vertex from set V1 and each vertex from set V2 are typically connected in a full bipartite graph.

Star Graph

An n-vertex star graph is a complete bipartite graph of the form K1, n-1. If there is just one vertex in the first set and every other vertex is in the second set, the star graph is a complete bipartite graph.

 

Conclusion

 

Data Structures and Algorithms play a vital role in acing an interview. Graphs form an integral part of Data Structures and Algorithms. In this article we have discussed the different types of Graphs. There are many applications for graphs. Google Maps uses the concept of Graphs. Dijkstra’s Algorithm is made use of in this concept. Candidates with immense knowledge in Data Structures course (DSA) are preferred by top product based companies. There are many training institutes in our country which equip candidates with strong DSA skills. At SkillSlash, candidates are provided 1:1 training. They are made to work on live projects and give a guaranteed job referral program. Skillslash also has in store, exclusive courses like Data Science Course In Chandigarh , Full Stack Developer Course in Mumbai  and Data structure online course to ensure aspirants of each domain have a great learning journey and a secure future in these fields. Contact the student support team today to know more about the program and how it can benefit you.