IMPLEMENTATION OF GRAPHS IN C++.
Graphs are mathematical structures that reflect the pairwise relationship between things. A graph is a type of flow structure that displays the interactions of several objects. It may be represented by utilizing the two fundamental components, nodes and edges.
Nodes: These are the most crucial elements of every graph. Edges are used to represent node connections. For example, a graph with two nodes connected using an undirected edge shows a bi-directional connection between those two nodes.
Edges: Edges are part of a graph showing the connections between nodes. An edge represents the connection between two nodes.
An application in real life ::
Google Maps: link your journey from the start to the end. Social Networks: friends are connected with each other using an edge where each user represents a vertex. Recommendation System: relationship data between user’s recommendations uses graphs for connection.
Type of graphs ::
Undirected: All edges in an undirected graph are bidirectional and do not point in any particular direction. Directed: In a directed graph, all edges are unidirectional; they point in a single direction. Weighted: Weighted graph, with each edge, allocated a weight or cost. Consider a network with four nodes, shown in the picture. Every edge of a graph has some weight with it. Cyclic: If a graph contains a path that starts and finishes at the same vertex, it is said to be cyclic. This is referred to as a cycle. An acyclic graph does not have a cycle.