Graphs in the field of software engineering are a container type geared towards traversing from one node to another. The difference between graphs and trees is that graphs can be circular or contain a loop. There are edges (the connection between two nodes) and vertex (or node). To move within a graph, an edge that connects the nodes must be traversed.
Sometimes edges are bi directional, but they my also be uni directional. Some ways we think to traverse the nodes Depth First Search (experience each location and everything that leads from that location) and Breadth First Search (hop around from location to location based on locations you see from your current location). Think amusement park .. which method do you use to get on rides at an amusement park?
We use graphs for many different applications. For Google Maps! For example, a graph is used to get you from one location to another. You traverse through a bunch of edges (roads, highways, bridges) that are connected by nodes (street addresses) until we get to your final node (the street address you chose to arrive at). Of course both edges and nodes can carry auxiliary data to allow us to know if a street is one-way or what side of the street the address is on etc.
Now that we have navigation, apps like Uber and Lyft can compound on that functionality to create jobs for many Americans abstracting the map portion (Google Maps! Or Native Lyft Uber apps) to map software, and creating the business through business logic and fairness. The map (graph) literally allows the job to be performed. No map, no Uber or Lyft (how terrifying). It is really remarkable how technology can change the world!
Some social networks also use Graphs as their underlying data structure. A graph can explain relationships and give degrees of separation from a node. Networks such as Facebook and LinkedIn depend on these relationships to give their networks an edge. These can only be expressed efficiently with graphs. Building a social network with graphs as your underlying structure vs any other container can give huge advantages as far as the underlying architecture and the insights you are able to communicate to the user. The information that can be uncovered mimics the real world better than any other structure.
Graphs are also used big time in the gaming environment. You will most likely have a navigator where you can traverse the world you exist in and a map with visited and unvisited areas. This clearly uses a graph in much the same way a maps program uses GPS to get you from one place to another. In addition to the maps, traversing the actual land requires you to traverse an edge of the world. There may be auxiliary data to make it look cool, but at the end of the day, an edge must be traversed. Having knowledge of this fact can help you as you play different games. I use this knowledge all the time, but then again, Iām a programmer š .
So as we can see, graphs are an amazing advanced data structure that have many applicable uses. Of course these structures are combined with other structures, but I know as I progressed my knowledge in the field of software engineering, it may have helped to know some of these examples. Graphs are certainly more complex than other simple data structures, but the power they possess is unyielding. Have you to use graphs as the main container in a software program? What are your experiences with graphs and any pitfalls? Let us know below!