Practice question · Sort into groups
Sort each relationship by the kind of edge that models it.
Groups: Directed edge · Undirected edge · Weighted edge
- Account A follows account B, but not the other way round
- One web page contains a link to another page
- The road between two towns is 12 kilometres long
- Two atoms are joined by a chemical bond
Hints
- Ask two separate questions: does the relation run one way or both, and does it carry a number?
- Following and linking are famously one-way; friendship and bonding are mutual.
Show the answer
Directed edge: Account A follows account B, but not the other way round, One web page contains a link to another page
Undirected edge: Two atoms are joined by a chemical bond
Weighted edge: The road between two towns is 12 kilometres long
Why
Direction and weight are independent choices: a relation is one-way or mutual, and separately it may or may not carry a cost, distance or capacity. Modelling a one-way relation as undirected quietly invents connections that do not exist, which is how graph models of social networks go wrong.
Practise Graph Representations
The app has 7 more questions on this lesson, and keeps your place in the course. Computer Science I is free to start.