Member-only story

Don’t Understand Graphs? Here’s Why You Should Study Graphs in Computer Science

Bennett Garner
5 min readDec 15, 2018

--

Graphs are everywhere, all around you! But chances are you don’t really understand them.

A directed, weighted, cyclic graph. A lot of jargon. Don’t worry, I’ll explain.

For many self-taught devs, graphs can be intimidating and difficult to learn.

For that matter, graphs can be baffling to experienced devs and computer science grads who haven’t worked with them for a while.

But graphs are cool and vital ways of representing information and relationships in the world around us. We can use graphs to do amazing stuff with computers, and graph algorithms offer a lot of tools to understand complex networks and relationships.

In this simple post, I’ll expose you to the basics of graphs. Nothing too fancy, complex, or mathematical here. Just the essentials. By the end, I hope you’ll see why they’re worth learning about and playing with.

A little motivation

Before we dive into the theory, I thought I’d provide some motivation for learning graphs in the first place. What are graphs and what can we do with them?

At its most basic, a graph is a group of dots connected by lines.

That’s the essential picture you need in your head. All the complicated notation you find in comp sci textbooks (e.g. G(V, E)) is simply a way to abstract the concept of dots connected by lines.

We use graphs to model relationships in the world. For example:

  • Google Maps uses a series of dots and lines to model the road network and give you directions to your final destination
  • Facebook friend networks are a graph where each person is a dot, and the friendships between people are lines
  • The Internet is a giant graph, where web pages are dots and the links between pages are lines

We can model objects in physical space, relationships between people, and document structures all using graphs, simple dots and lines!

The upshot is once we have the relationships modeled, we can:

  • Find the shortest path between two points
  • Identify groups of relationships
  • Store data and create links between it in almost…

--

--

Bennett Garner
Bennett Garner

Written by Bennett Garner

DeveloperPurpose.com — Build a coding career with meaning and purpose 💻 Top writer in technology ✍️

Responses (1)