What are graphs and what can we do with them?
Much of this is review from The Simple Reference To Graphs
. If you already have the basics down, feel free to skip to the implementation parts later in the guide.
In purely layman's terms, a graph
is a group of dots connected by lines. You've seen them plenty of times. Programmatically, these "dots" represent things, and these lines are to demonstrate connections between things. We can use graphs to model relationships in the world.
For example:
Facebook friend networks are a graph where each person is a "dot" or a
node
, and the friendships and connections between people are lines.Google Maps uses a series of nodes and lines to model the road network and give you directions to your final destination.
The Internet is a really a giant graph where web pages are dots and the links between pages are lines.
We can meaningful model groups of relationships, find relations between people, find the shortest path between two points, model objects in space, and document structures all using this concept of nodes connected by edges.
