seegongsik
Saved words
Data

Linking data with dots and lines, the graph

Say you write friendships in a table. Listing who is friends with whom row by row, finding a friend of a friend means digging through the table again and again. But what if you draw each person as a dot and each friendship as a line? From one dot you just follow a line to reach a friend, and follow that friend's line to see a friend of a friend right away. Holding relations with dots and lines like this is a graph.

01

Hold relations as dots and lines

Earlier we learned to hold values
lined up by slot numbers.
But for some data,
the relation between things matters more than each value.
Like who is friends with whom.
Lining such data up feels awkward.
So we draw each person as a dot,
and each friendship as a line.
With just dots and lines, the relation is held as is.

ABCDE
dot = person line = friendship
Tap two people in turn to link them with a line

Tap two people in turn to link them with a line. Dots are people, lines are friendships.

Once dots were linked, the relation became visible.
Who is connected to whom,
you can tell just by looking at the lines.
It lands far more like a picture
than rows written one by one in a table.
Dots are things, lines are relations.
Data held with these two is called a graph.
Then if we follow these lines,
what can we find out?

02

Along the lines to a friend of a friend

Let's start from one person.
Follow the lines tied to that dot,
and right away that person's friends appear.
Without stopping there,
follow the lines tied to a friend's dot too,
and a friend of a friend appears.
Stepping one hop farther like this,
you reach acquaintances of acquaintances.
This is how recommendations are made.

meP1P2P3P4P5P6
me friend friend of a friend
Tap the start dot (me) to light up friends first

Tap one person to light up friends, tap again for friends of friends, step by step.

One tap lit up friends,
another tap lit up friends of friends.
How far someone is from the start
is set by how many lines you crossed.
One line away is a friend,
two lines away is a friend of a friend.
With a table you would have dug
again and again to find this.
Following lines, it is this easy.

03

Follow neighbors to tour the group

Dots linked by a line straight to one dot
are called that dot's neighbors.
From one dot to its neighbors,
then to the neighbors of those,
let's keep spreading along the lines.
In time there is nowhere left to go.
The dots reached by then
are one group connected to each other.
A dot with no line in does not join it.

N1N2N3N4N5X1
Tap a neighbor of a lit dot to spread one hop

Tap a neighbor touching the lit group's edge to spread one hop. Only connected dots light up.

Spreading along neighbors,
the connected dots lit up one by one.
Wherever a line reached, you could tour.
The separate dots, on the other hand,
never lit up no matter how far you went.
Whether a line connects them is what splits the groups.
Following neighbors like this
is easy in a graph, since you just watch the lines.
But what if you did the same with a table?

04

By table, or by graph

Say friendships are written in a table.
To find a friend of a friend,
first look up friends in the table and note them,
then for each friend dig through the table again.
Every time you go one step farther,
you scan the table from the top once more.
With a graph, follow a line from a dot,
then follow a line from that dot, and you are done.
When relations are the point, a graph is far handier.

Find all friends of my friends
Solve by table
0 taps
Solve by graph
0 taps

Solve the same "friend of a friend" question by table and by graph. Compare how many taps each takes.

By table, finding the same answer
took far more taps.
Because it meant looking up again and again.
The graph followed lines twice and was done.
Of course a table is not bad.
For writing things straight, row by row, a table is great.
But for tasks that follow relations,
a graph that holds them as dots and lines
is far more natural and fast.

05

Let's wrap up

Gathered on one line, it is this.
Hold things as dots and relations as lines.
That is a graph.
From one dot, following a line gives a neighbor,
and following the neighbor gives a friend of a friend.
Spread along lines and a connected group appears.
For tasks where relations are the point,
what a table makes you dig for, you reach by just following lines.
Dots are things, lines are relations, follow neighbors. That is a graph.

Tap the key points in order to review

Tap the key points in order to review. (dots are things, lines are relations -> friend of a friend -> follow neighbors -> graphs for relations)

Now you know how to hold relations as dots and lines
and roam by following lines.
A friend of a friend, awkward by table,
was reached in two lines on a graph.
Depending on what shape you give data,
the same task gets easier or harder.
The eye for choosing that shape
is the power of handling data.
Let's keep exploring together next time too.

In one lineA graph holds things as dots and the relations between them as lines. Put people as dots and friendships as lines, and the connections show at a glance. From one dot, following a line gives a neighbor, and following the neighbor's line gives a friend of a friend. Spreading along lines like this, you can tour a whole connected group. For tasks where relations are the point, like recommending or finding connections, what a table would make you dig for again and again, a graph lets you reach by just following lines. In short, dots are things, lines are relations, and you follow neighbors. That is a graph.
Data
Was this helpful? Support seegongsik