A graph consists of noes and edges between nodes.

A directed graph $G$ consists of a nonempty set $V(G)$, called the vertices of $G$, and a set $E(G)$, called the edges of $G$.

A directed edge starts at some vertex $u$ called the tail of the edge, and ends at some vertex $v$ called the head of the edge. The notation $\langle u\to v\rangle$ represents this edge.

An undirected graph $G$ is a pair $(V, E)$, where $V$ is a set of vertices or nodes and $E$ is a set of edges or branches; an edge is a set $\{v,v'\}$ of two not necessarily distinct vertices (i.e., $v, v' \in V$).

A walk in graph $G$ is an alternating sequence of vertices and edges, starting and ending with a vertex, where, for every edge $(u,v)$ on the walk, $u$ is the preceding vertex and $v$ is the following vertex.

Graphs and Relations

Composing and Inverting Functions

If $R$ is a relation on $A \times B$, then $R^{-1}$ is a relation on $B \times A$.

$$ (a,b)\in R \iff (b,a)\in R^{-1} $$

If $R$ is a relation on $B \times C$ and $S$ is a relation on $A \times B$, then $R \circ S$ is a relation on $A\times C$:

$$ (a,c) \in R \circ S \iff\exists b(a,b)\in S\land (b,c)\in R $$

Example: If $R \ \{(n,n+1): n \in \N\}$, then what's $R \circ R$?

Given a relation $R$ on $S \times T$, we can represent it by the directed graph $G(V,E)$, where

A relation $R$ on $S$ is reflexive if $(x,x) \in R$ for all $x\in S$