1

I am looking at a definition for an induced subgraph. I completely understand what an induced subgraph is, so an explanation of that is beside the point. What I am really interested in is a specification of the notation mechanics used in the definition:

$$ G'=(W,F) \text{ is an induced subgraph of } G = (V,E) \text{ when }\\ W \subseteq V \text{ and } F = \{ xy \in E : x,y \in W\} $$

Mostly what I am interested in is a verbal explanation of:

$$ \{\dots : \dots \} $$

Because my interpretation: "F is every xy in E where both x and y are in W" seems to be a subset of what can be communicated using the braces-colon notation...and, in pseudo code, it would be: "for i in E( if: for all j in i, j is in W, then: i is in F)"... but, again, I don't think that is the fundamental structure of the braces-colon notation.


Honestly, I would prefer an explanation in computer code--for loops, etc. Because it appears that both a for loop is implied in the left hand position (dots), and a for loop, a conditional, or a conditional + for loop can be implied in the right hand position (second set of dots).

But a verbal explanation of the braces--is the result inside the braces always a set?--the rules for the left hand box, the ":" and the rules for the right hand box would be awesome.


Also, how is $$ \{ \dots : \dots \} $$

different than another set comprehension I've seen recently,

$$ \{\dots | \dots \} $$


As it is, my level of understanding of the $\{\dots : \dots\}$ notation is such that I have to know the meaning intended before I read the notation in order to understand it.

Asaf Karagila
  • 405,794
Chris
  • 508
  • More specifically, can anyone translate the notation into a set of functions and an English sentence? Because it is definitely a function, from a programming point of view... And the fact that this is just brushed over with this notation is frustrating, because, in terms of computational complexity, the statement in the braces is actually pretty high. – Chris Mar 05 '16 at 16:49
  • Can you double check that definition of $F$ again: Is it in fact $x, y \in W$, rather than $V$? – pjs36 Mar 05 '16 at 16:53
  • 1
    yup, there it is...V -> W. – Chris Mar 05 '16 at 16:55
  • $F={ xy \in E : x,y \in W }$ means that $z \in F$ if and only if there exist $x,y \in W$ such that $xy=z$. If $W$ is finite, then you could build F like this: F=emptyset; for x in W, for y in W, F.insert(xy) – Ian Mar 05 '16 at 17:05
  • Right, I understand what it means...but what does the notation imply? In other words, what is the generic function, ${ \dots : \dots }$? – Chris Mar 05 '16 at 17:07
  • For each collection of values of the variables satisfying the conditions on the right side of the colon, the value on the left side of the colon is in the set. No other values are in the set. I don't know how to cleanly write that in terms of a loop, because the shape of the loop depends on the number of variables and whether there are additional conditions on the variables (other than just coming from some set). – Ian Mar 05 '16 at 17:09
  • Cool, thanks. So it is constrained to sets, constrained exactly on the left hand side by the condition on the right hand side. So I can add conditions on the right hand side, and add elements I'm going to include on the left hand side. It was unconstrained in my understanding, and was very frustrating. Thank you. – Chris Mar 05 '16 at 17:12
  • @Ian do you know about the vertical bar? Is it "Where ...", so condition on the right hand side and entries on the left? – Chris Mar 05 '16 at 17:14
  • 1
    A vertical bar is the same as a colon. – Ian Mar 05 '16 at 17:20

2 Answers2

2

Think in the adjacency matrix, $M$, of the graph $G$: $M=(m_{i,j})$ for $i,j \in \{1,\ldots ,n\}$ such that $m_{i,j}=1$ iff the vertex $i$ is connected with the vertex $j$. So your input is a subset $W\subseteq V$ (you can give $W$ a specific data structure of you want) so how do we build the subgraph from the subset $W$? Look that $M$ is symmetric so you just need to look on the upper part of the matrix, look for all the ones in the first row of $M$ and then ask if the vertex $i$ and vertex $j$ is in $W$ if it is then you put this edge in your adjacency matrix of $G'$ and then continue to the other rows, here you can use the fact that $M$ is symmetric and finally you got the adjacency matrix of the induced subgraph by $W$.

Erick
  • 486
  • Hmm, ok. as I understand it, $W\subset V$ means $W$ is strictly smaller than $V$ – Chris Mar 05 '16 at 17:05
  • @bordeo The symbol $\subset$ sometimes means proper subset or sometimes just subset, it depends on the author (and is often defined in the notation summary of the text in question). $\subseteq$ specifically permits equality and $\subsetneq$ specifically forbids equality. – Ian Mar 05 '16 at 17:07
  • Well, you're right it should be $W\subseteq V$ – Erick Mar 05 '16 at 17:07
  • @Ian thanks. My teacher is ridiculous about her notation. She is a grammar natzi...and answers zero questions. That is how I thought it was defined a few months ago, and she got on my case. – Chris Mar 05 '16 at 17:10
2

Both formats $\{\ldots : \ldots\}$ and $\{\ldots \mid \ldots\}$ are examples set-builder notation, with $:$ and $\mid$ both read as "such that".

So I read $\{xy \in E : x, y \in W\}$ as "The set of all edges $xy$ such that $x$ and $y$ are $W$" literally, or, a little more naturally, "The set of all edges $xy$ where $x$ and $y$ are in $W$." If you're thinking something along the lines of "Put every $xy$ in $F$ for which $x$ and $y$ are in $W$", then you're thinking exactly right.

I suppose pseudocode would look something like

For xy in E:
    if (x is in W and y is in W):
        put xy in F

although pseudocode is not my specialty!


The general format of set-builder notation is something like $$\{[\text{what things in the set look like}] : [\text{what needs to be true of those things}]\}.$$

  • The left part of a set-builder construct is usually a formal description of members of some auxiliary set $A$ (sometimes as simple as "$x \in A$", sometimes more complicated, like "$x^2 - y^2$", etc).

    • Sometimes $A$ is a set that's already laying around, sometimes it's a set that is "initialized" when we write down our set. For you, the set $E$ of edges was already laying around, and we just decided which edges to include.
  • Then, the right half is simply some condition that is checked for each item in the auxiliary set $A$: you include an element $a \in A$ in your set, if and only if this condition is true for $a$.

Sometimes things are a little backwards; the right hand side will consist of the set we'll iterate over, and the left side will be things we'll include. An example like this would be to write the set of even integers as $\{2k : k \in \Bbb Z\}$. Here my perspective shifts, and I tend to think of the set as "Put $2k$ in our set, for each $k \in \Bbb Z$ we encounter," from a construction viewpoint.

I'm not a historian, but I would guess set-builder notation somewhat haphazardly evolved to include more flexibility to define, at the cost of not having a single, fixed structure, when it comes to actually constructing said sets (at least, maybe until you zoom way out -- I'm not a logician either, but a lowly working mathematician!).

The above-linked Wikipedia article is much more thorough, if you really want to get into all the gritty details.

pjs36
  • 18,400
  • This makes a lot of sense. Thanks. I think I hit on both versions in the last chapter (edge subset and something similar to the even set)... – Chris Mar 06 '16 at 16:13
  • @bordeo I'm glad it helped. I've been tearing my hair out trying to get students to use set-builder notation correctly in a sort of remedial algebra class. But having sat down and attempted to define it more formally might make me a bit more sympathetic in the future :) – pjs36 Mar 06 '16 at 18:34
  • Yeah, sometimes I think "mtah can be a ltitile lkie raednig" where you can understand what is going on immediately when you are practiced, but I cant imagine teaching a person how to read without standardizing the order of everything, and showing why--associating the letters with sounds, etc. So simple things become complex to teach from an expert position... – Chris Mar 07 '16 at 21:47
  • Also-I actually think it is fairly abstract, and a lot of things are going on. For instance: ask a student to explain why: $ x \in E \neq F = {x \in E} = E$. (and when you compare ${x}$ to ${_ \in E }$ and ${E}$, you see that the context is changing the definition of $_ \in _$ from a prepositional relation to some kind of function...and, similarly, $F = { x }$ is a prepositional relation...but now ${ x \in E}$, a combination of prepositions, is a function?? That is some mind bending grammar for a native English speaker...whereas '{ for every x in E yield x }' is trivial...) – Chris Mar 07 '16 at 22:28
  • In other words, I think the english version, in terms of logic and grammar, would be ${ \forall x \in E : \rightarrow x }$, or ${\forall x \in E: \text{ _ } \rightarrow x}$...but if you already know set builder notation, that looks backwards....while in english, it starts with your set of objects, applies the filter, and generates an output set of objects, left to right, so that when you are done reading left to right, you are left with the objects. Set builder, on the other hand, has a latin order--final objects first, conditions/adverbs/adjectives/assembly objects last. – Chris Mar 07 '16 at 22:36