-
Book Overview & Buying
-
Table Of Contents
The Complete Coding Interview Guide in Java
By :
A graph is a data structure that's used to represent a collection of nodes that can be connected with edges. For example, a graph can be used to represent a network of members on a social media platform, so it is a great data structure for representing real-life connections. A tree (as detailed in the previous section) is a particular type of graph. In other words, a tree is a graph without cycles. In graph terms, a graph without cycles is called an acyclic graph.
The specific terminology for graphs involves two main terms:
The connection can be unidirectional (as in the case of binary trees) or bidirectional. When the connection is bidirectional (such as a two-way street), the graph is known as an undirected graph and it has undirected edges. When the connection is unidirectional (such as a one...