Types of Graphs
There are two main types of graphs:
1. Directed Graph
There is a one-way relationship between the connected nodes. For example, in a directed graph representing a website’s link structure, if there is a link from page A to page B, it doesn’t necessarily mean there’s a link from page B back to page A. So, directed edges show us one-way connections between nodes, like the links on a website that point from one page to another.
2. Undirected Graph
Undirected edges in a graph are like a two-way street where traffic can flow in both directions. For instance, in a social network graph, if there is a connection between two people, it means they are friends with each other. It’s like saying they have a mutual connection, without specifying who is initiating the connection.
How to Implement Graph in Ruby?
Graphs are basic data structures that represent the connections between different items. They are made up of edges (links) that show the connections between the entities and vertices (nodes) that represent the entities themselves. Numerous applications, such as social networks, navigation systems, routing algorithms, scheduling issues, and more, heavily rely on graphs.
Table of Content
- What is a Graph?
- Types of Graphs
- Implementing Graphs in Ruby
- Conclusion
Contact Us