Courses/Computer Science/CPSC 203/CPSC 203 Template/Lecture Template/Lecture 4

Housekeeping
(none)

Required Reading
There is no specific required reading for today's lecture.

Next week's lectures will begin examining spreadsheets as a problem solving medium. The required readings for next week from the textbook fluency ... are:
 * Chapter 14. Fill-in-the-Blank Computing. pp 374-406.
 * Chapter 15.  "What If" Thinking Helps. pp 411 -437.

Introduction
This is the final of our introductory lectures to build up a vocabulary for problem solving. So far we have been introduced to the following concepts (which will be elaborated through the rest of the course)

In the first two lectures we introduced terms that can be applied to simpler problems (which are usually single faceted):


 * Algorithm (a mechanical process for solving a problem in a step-by-step manner)
 * Heuristic (a rule of thumb for solving a problem)
 * Hypothesis (a provisional idea whose merit requires evaluation)
 * Error (the difference between an expected value, and the value actually observed).

In the last lecture we introduced some terms that can be useful in examining more complex problems (which are often multi-faceted, and break down into sub-problems whose solutions must all work together)


 * System ( a group of elements that work together)
 * Design ( the act of trying to define a harmonious assemblage of the components of a system)
 * Evolution ( the tendency of complex systems to undergo irreversible change with time)

In this lecture, we introduce one final term, that helps us grasp the essence of a problem:  a model 

There are many ways to build models. We introduce one simple approach, that is very common in computer science: We can build models of systems by drawing graphs -- simple sketches with dots and edges. While very simple to draw, such graphs can be used to summarize a lot of information, and can be used as a tool to reason about a problem.

To be able to use graph models as a tool in problem solving, we have to introduce a small vocabulary of terms that describe parts and properties of graphs (see glossary).

Too illustrate the role of building simple graph models we will introduce some future topics in the course that use just this graph modelling approach (e.g. Data Models in databases, Decision and Attack Trees in Security, Circuit Diagrams in Programming Logic.).

At the end of today's lecture you should understand:
 * What a Model is.
 * How to use graphs to draw models for a problem (as indeed you did, in developing alternate Internet designs last class).
 * Some very basic terminology from Graph Theory that allows you to reason about graph models

Glossary
The brief definitions in this section will be illustrated .... graphically. Our goal is to introduce the terminology, and an intuitive understanding of it, via sketches of graphs.


 * Model -- A model is a simplified representation of a system. For example a road map, or a map of a new residential neighbourhood you might want to buy into. In a mathematical model we represent a real life situation or problem with a mathematial system (in our examples, the mathematical systems are graphs).
 * Dot ---> Also called :"Node", "Vertice", "Object"
 * Edge ---> Also called: "Relation", "Connection", "Arc".
 * Graph -- A graph has a set of dots, and a set of edges, where each edge can be represented by a pair of dots. For
 * Subgraph -- A graph H is a subgraph of G if the dots and edges in H are also in G.
 * Isomorphism -- Two graphs are 'isomporphic' if they have the same structure, that is you can map every dot and edge in one graph to the other. Note -- this is a mathematically difficult idea. Isomorphism functions a lot like "equality" when comparing graphs.
 * Types of Edges
 * Undirected Edge (--> Graphs).
 * Directed Edge (---> Directed Graphs)
 * Various routes through a graph
 * Walks --A walk is an alternating sequence of dots and edges, such that every edge joins the dots immediately preceding and following it.
 * Trails -- A trail is a walk where no edge is repeated.
 * Paths --A path is the list of dots, and edges that does not repeat any dot.
 * Cycle -- A cycle is a trail with at least 3 edges, that begins where it ends, and does not repeat any dots (except the first and the last).
 * Types of Graphs
 * Trees -- Formally, a "tree" is a graph in which any two nodes are connected by exactly one path. A directed tree is a graph with directed edges where every node has a single parent, and potentially multiple children.
 * Directed Acyclic Graphs (DAG) -- More complex than directed  trees -- the only restriction now is that there are no cycles.
 * Networks -- Directed Graphs where the edges have a value.
 * Connected/Disconnected -- Two nodes are connected if there is a path between them, otherwise disconnected
 * Component -- A connected subgraph of a graph. Intuitively, "pieces" of a graph that are not connected to each other.

Graphs and Models
One of the early examples of problem solving using graph models is the famous problem (to mathematicians and computer scientists at least) called The Seven Bridges of Konisberg

http://en.wikipedia.org/wiki/Seven_Bridges_of_Königsberg

Konigsberg was a city located on two sides of a river, and included two large islands which were connected to each other via seven bridges. The problem was: Is it possible to walk through the city and cross each bridge once and only once. The mathematician Euler, proved it was impossible. He began by drawing a sketch of the situation ... a graph, where part of the city was a dot, and each bridge was an edge, connecting two parts of the city.

That is, Euler stripped away the details of the city of Konigsberg, to develop a model that was a simple graph.

Dots and Edges
The various items in the glossary above are illustrated on the overhead providing key examples. The key idea here is that we can use graphs to develop visual models. These models can be mathematically formalized (which is beyond the scope of our course). But they also provide:
 * 1) A way to visualize a problem concretely
 * 2) A way to reason about the problem by looking for paths, cycles, subgraphs, isomers

and in this way, even without the mathematical formalism, you have a visual toolkit that helps you think critically about different kinds of problems.

Some General Examples

 * Graphs as Mathematical Models -- Several Islands, Several ferry boats going amongst the islands.


 * Directed Graphs as mathematical Models -- At a large firm, we identify each person as a node, and draw an arc between managers and the managed.


 * Networks as Mathematical Models -- A neighbourhood with several families. Families may like (1), disliike (-1) or be indifferent (0) to each other.

Some Examples from the Course

 * A Data Model in a Database
 * A Complex circuit
 * An Attack Tree

Summary

 * We can often model a situation or a problem by drawing a graph
 * If we can represent a situation as a graph, we can reason about it, using basic ideas from graph theory.
 * Various kinds of problems throughout this course will have their essential features represented as a graph

Text Readings
see the readings listed above under "Required Readings"

Resources

 * Introductory Graph Theory by Gary Chartrand. Excellent discussion on the relationship between graphs and models. Most of the glossary definitions used in this lecture are drawn from this book.


 * Introduction to Graph Theory By Richard J. Trudeau. Dover Press, 1993. Originally called, "Dots and Edges" -- if you find playing with dots and edges fun, and want to learn more --- this is the place to start. You can usually find a copy at a used bookstore's math section for < $10


 * Graph basics -- http://en.wikipedia.org/wiki/Graph_(mathematics)

Homework
Practicing graph modelling.

Using the ideas from this lecture, draw a graph model of:
 * how you would diagnose someone with chicken pox
 * how you analyze a question in a multiple choice test
 * how you would represent a friends network on a a social networking site like facebook, myspace, etc.

Questions

 * /Lecture 4 Questions