It's a world-wide webby wonderland.. Graphs are often used to represent real-world information...

Preview:

Citation preview

It's a world-wide webby wonderland.

Graphs

Why?

• Graphs are often used to represent real-world information and real-world structures.

• Graph Theory was even invented to solve a real-world problem.– The city of Kӧnigsberg was located on the Pregel river in Prussia.

The river divided the city into four separate landmasses, including the island of Kneiphopf.

– These four regions were linked by seven bridges. Residents of the city wondered if it were possible to leave home, cross each of the seven bridges exactly once, and return home.

– Leonhard Euler (a mathematician) and solved it by converting it into a graph

Example

Essential Information

Example: Air routes

Other examples

• Some courses have pre-requisites. Are there any courses at UW-L that can't be taken because they are pre-requisites to each other (even indirectly via a third course)?

• Construct a schedule for building a house. what are the most critical (in terms of time) parts of the construction?

• Send a signal from your cell phone to your friends cell phone in Taiwan.

• Download a web page from Russia.• Whats the best NFL/MLB team?

Graph

VertexArc

Basic terms• A vertex is a node in the graph• An arc is a an ordered pair of vertices

– The arc might connect one vertex to itself.– The arc is one-way (FROM, TO)

• When drawn, a vertex is usually a circle (dot) and an arc is a line between the circles where the directionality is given by an arrow.

• A graph G consists of a set of vertices V and a set of arcs E. For example:– Let G = (V, E)– where V = {1,2,3,4,5,6}– and E = {{1,2}, {1,5}, {2,3}, {2,5}, {3, 4}, {4, 5}, {4, 6}}

Models and Views• A model is an abstract description of a system. A graph is a

mathematical model.– G = ({a,b,c,d,e}, {(a,c), (a,b), (c,b), (c,e), (d,b), (d,d), (e,d)})

• A view is a way to visualize a system or part of a system. A drawing of the model is a view.

• For one model, there may be many views.

• Vertex A is adjacent to vertex B iff (A,B) is in E.• A loop is when a vertex is listed first and last in an arc.• The in-degree of a vertex V is the count of arcs of the form (_, V).

The number of arcs TO the vertex• The out-degree of a vertex V is the count of arcs of the form (V, _).

The number of arcs FROM the vertex• The order of a graph is the number of vertices• The size of a graph is the number of arcs

Terminology

G = ({a,b,c,d,e}, {(a,c), (a,b), (c,b), (c,e), (d,b), (d,d), (e,d)})

• A path is a sequence of vertices [V1, V2, V3, V3, …, Vn] such that– For every pair of adjacent vertices Vi and Vj in the path, there is an arc (Vi,

Vj) in the graph.

• The length of a path is the number of arcs in the path. The length can be zero for the case of a single vertex.

• Vertex Vj is connected to vertex Vi iff there is at least one path that starts at Vi and ends at Vj

• A cycle is a path where– length > 0 – It starts and ends with the same vertex

• A graph with no cycles is acyclic.

Terminology (Paths)

• Define G• Give the size and order of G.• Is [F, E, C, D] a path?

– length?– weight?

• What is the degree of E? Of A?• Is H connected to A?• Is A connected to H?

Example

Trees : a Special Kind of Graph• A tree is a graph such that

– It has one vertex with in-degree 0. This vertex is known as the 'root'.– Each non-root vertex has an in-degree of 1– There is a path from the root to every other vertex

Trees : a Special Kind of Graph

• Some vertices have an out-degree of zero. These vertices are called leaves. There may be many leaves in the tree.

• A tree is an acyclic graph.

Organizational Chart

Taxonomies

Decision trees

File System

Recommended