[an error occurred while processing this directive] Reading: 7.1, 7.3(digraphs), 7.5.

Relations

As mentioned during logic and interpretations: a Relation is just a subset of (tuples of) the domain. For instance, the binary relations ``likes(,)'', ``hasCoStarredWith(,)'', ≥. Or unary relations like safe?(), has3?().

Binary relations are particularly interesting: Consider domain {Ian,Gillis,Leebron} and the relation hasHeardOf(,). We can show this particular relation as a list: hasHeardOf = { , , , }

We can also give a pictorial relation:

This is called ``directed graph'', or sometimes just ``digraph''.

Graphs can be considered equivalent to listing a particular relation. But they're common in their own right: Def'n: A Graph G is a tuple ⟨V,E⟩ where V is a set of vertices, and E ⊆ V×V is a set of directed edges. Note that a graph is not tied to one particular way of drawing; you can move edges (and stretch incident edges) around in the picture, change whether edges are drawn crossing over other edges, etc, and it's still the same graph. (We refer to the embedding of a graph, if the geometry is important.)

Draw the graphs of some particular relations: K_n: the domain of n nodes, where everything is related (including self). ``The complete graph''. The discrete graph: nothing related to anything else. Equality: things related exactly to themselves. Subset-of, on domain P({1,2,3}). thinks-is-cute on domain of people.

Digression:
Trees differ from (undirected) graphs in that trees can't allow cycles. But consider these graphs which are "almost" trees:
...[show some picts]...
This might well be a LAN (or internet) layout. Can we formalize the notion of 'nearly a tree'?

 - How?  Go home and think about it.
 - One idea: "tree width": If you squint and consider several nodes
   to be all one big node, then it might look like a tree.
   Draw some pictures/examples to develop this idea.
   We say that the "tree width" is the size of the largest set you had 
   to collapse; "Small tree width" is a quantitative idea of tree-like.
   [You can think of other ways to count, of course.]
   - What are trivial cases?
Exercise: write down a formal def'n of tree-width (using sets, functions, etc). Hint: create a *tree* whose nodes are entire *sets* of original graph nodes. (What is an idea of edge?)
Note: sadly, calculating tree-width is "NP-complete" in general: nobody knows a polynomial-time algorithm for it.

Properties of Binary Relations

For each of the following properties,

Def'n: A binary relation R(,) on domain D is …

There is a special term for relations which are reflexive and symmetric and transitive: Equivalence relation.
Which of the examples above are equivalence relations?
Some other examples: has-same-zipcode-as(,), has-same-zodiac-sign(,); same-college(,); same-top-level-Class(,).
[Okay, we realize we're perhaps glossing over foreigners, homeless, dual residences, people whose birth spanned a cusp, and haven't fully specified how the relations work in those cases.]

We say that an equivalence relation partitions the domain into equivalence classes.

Def'n: equivalence class: The equivalence class of a under relation R = { b in domain | R(a,b) }

Def'n: partition [finite]: a set of sets {A1,A2,…,An}

[Alternately, these conditions can be defined closer to the English, and then we could prove they're equivalent.]
We can easily extend this to allow infinite partitions: a set A* of sets, such that ∪A ∈ A*a = domain, and ∀ A1,A2 ∈ A*, A1 ≠ A2 → A1 ∩ A2 = ∅.

Equivalence relations are interesting because one can create a new domain whose elements are just the original equivalence classes; it's a way of boosting a relation into its version equality. Example we'll see later: the relation ``remainder upon dividing by 7'' partitions the integers into 7 equivalence classes. The set Z/7 (``Z mod 7'') is a new set with 7 elements.

[an error occurred while processing this directive] [an error occurred while processing this directive]