LOGBOOK

HELP

← again tap: answer good → ↑ swipe up at the end: next

1 / 9 Part 1 of 3
Other keys: show • Space: good • 1-4: rate • 0: skip • 5: flag

Question

What is a graph $G = (V, E)$, and what do its vertices and edges store?

Answer

vertices, and edges between them SFOORDPVDLGAHNLLAXDFWMIA 1843849142337174380225551233138710991120 airport codes, route lengths SOL=SOLsame graph a 2nd route n = 8m = 11 only the connections count

Explanation in 5 steps

A graph is a pair of a set $V$ of vertices (nodes) and a collection $E$ of edges, each edge a pair of vertices. Vertices and edges can both store an element: in a flight network a vertex stores an airport code and an edge the length of the route between two airports.

Eight airports joined by eleven routes, each route labelled with its length in miles

* Only the connections count: where the airports sit in the picture means nothing. *

A graph models relationships: which things are connected to which. The vertices are the things, the edges the connections between them. Everything else in a drawing, the positions of the circles and the lengths of the lines, is decoration; two drawings with the same vertices and edges are the same graph. A route's length is part of the graph only because the edge stores it as its element.

$E$ is called a collection rather than a set because it may contain the same pair more than once (parallel edges, such as two different routes between the same two airports). Throughout, $n$ is the number of vertices and $m$ the number of edges: the example has $n = 8$ and $m = 11$.

Go deeper:

or press any other key

Question

What is the difference between a directed and an undirected edge, and when is a whole graph directed?

Answer

ORD PVD flight origin destination an ordered pair (u, v) ORDPVDroute both ways an unordered pair {u, v} ABCdirected graph DEFundirected graph roads, cables, routes one-way streets, flights,hyperlinks, dependencies in 2out 2 ordered pair: directed · unordered: undirected

Explanation in 5 steps

A directed edge is an ordered pair $(u, v)$: it leads from the origin $u$ to the destination $v$, like a flight from ORD to PVD. An undirected edge is an unordered pair $\{u, v\}$ that works both ways, like the route between ORD and PVD. A graph whose edges are all directed is a directed graph; one whose edges are all undirected is an undirected graph.

A directed flight ORD to PVD next to an undirected route ORD to PVD, and a small directed and undirected graph

* A flight has a direction and the return flight is a second edge; a route serves both directions. *

Which kind to use follows from the relationship being modelled. Symmetric relationships are undirected: a road usable both ways, a cable between two computers, a route between two airports. Asymmetric ones are directed: one-way streets, scheduled flights, hyperlinks from one web page to another, "A depends on B". In a flight schedule the flights ORD to LGA and LGA to ORD are two separate edges, each with its own flight number.

An undirected edge can always be replaced by two directed edges pointing in opposite directions, which is how some programs store undirected graphs. For directed graphs the degree splits in two: the in-degree counts incoming edges, the out-degree outgoing ones.

Go deeper:

  • doc Directed graph — terminology for directed graphs: in- and out-degree, sources, sinks, and the special kinds.
Each vertex is labelled (in-degree, out-degree): arrows in and arrows out are counted separately.
Each vertex is labelled (in-degree, out-degree): arrows in and arrows out are counted separately.
Melchoir · CC BY-SA 4.0 · Wikimedia Commons
or press any other key