Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Disc Lec6 - Graphs

Download as pdf or txt
Download as pdf or txt
You are on page 1of 36

FACULTY OF ARTIFICIAL INTELLIGENCE

AND INFORMATICS

Discrete Structure

Graphs

Computer Science department

1
Graphs

Graphs and Graph Models

Graph Terminology

Special Types of Graphs

Shortest-Path Problems
1. Graphs and Graph
Models

Discrete Structures (CS 104) 3


Introduction
A graph is a set of vertices (or nodes) represented by
circles which are connected by edges,
represented by line segments .

• Car navigation system


• Efficient database
• computer network
• Representing computational models
Graphs are used in a wide verity of
models:
• Social networks
• Communication networks
• Information networks
• Software design applications
• Transportation networks
• Biological networks
• Tournaments
Transportation networks

• Graph terminology often derived from


transportation metaphors
– E.g. “shortest path“, “flow“, “diameter“
Software Design Applications
• Graph models are useful tools in the design of software.
• Module Dependency Graphs One of the most important tasks in
designing software is how to structure a program into different parts,
or modules.
• Understanding how the different modules of a program interact is
essential not only for program design, but also for testing and
maintenance of the resulting software.

Web browser.
Communication Networks (1)

We can model different communications networks


using vertices to represent devices and edges to
represent the particular type of communications
links of interest
Communication Networks (2)
 Call Graphs: Graphs can be used to model
telephone calls made in a network, such as a
long-distance telephone network.

Three calls have been made from 732-555-1234 to 732-555-


9876
Social Networks
• Graphs are extensively used to model social structures based on
different kinds of relationships between people or groups of
people
Social Networks

Acquaintanceship and Friendship Graphs


We can use a simple graph to represent whether two people
know each other, that is, whether they are acquainted, or whether
they are friends (either in the real world or in the virtual world
via a social networking site such as Facebook).
Social Networks

Influence Graphs In studies of group behavior it is


observed that certain people can influence
the thinking of others
Social Networks
 Collaboration Graphs A collaboration graph is used to model
social networks where two people are related by working together
in a particular way.

 The Hollywood Links graph is a collaborator graph that


represents actors by vertices and connects two actors with an
edge if they have worked together on a movie or television show.

 The Hollywood graph is a huge graph with more than 2.9 million
vertices (as of early 2018).
Social Networks

Collaboration Graphs
 In an academic collaboration graph, vertices represent people
(perhaps restricted to members of a certain academic
community), and edges link two people if they have jointly
published a paper.

 The collaboration graph for people who have published research


papers in mathematics was found in 2004 to have more than
400,000 vertices and 675,000 edges,
Call Graphs
 Call Graphs: Graphs can be used to model
telephone calls made in a network, such as a
long-distance telephone network.

When we care only whether there has been a call connecting two
telephone numbers
Biological Networks
• Many aspects of the biological
sciences can be modeled using
graphs.
• Protein Interaction Graphs
– A protein interaction in a
living cell occurs when two or
more proteins in that cell bind
to perform a biological
function. Because protein
interactions are crucial for
most biological functions,
Tournaments (1)
Round-Robin Tournaments is a tournament where each
team plays every other team exactly once and no ties
(draws) are allowed
We see that Team 1 is
undefeated in this
tournament, and Team 3 is
winless
Tournaments (2)
Single-Elimination Tournaments is a tournament where
each contestant is eliminated after one loss
Semantic Networks (1)

• Graph models are used extensively in natural


language understanding and in information retrieval.

• Natural language understanding (NLU) is the


subject of enabling machines to disassemble and
parse human speech. Its goal is to allow machines to
understand and communicate as humans do.
Semantic Networks (2)
This figure to help determine whether mouse refers to an animal
or computer hardware in that sentence
2.Basic terminology

Discrete Structures (CS 104) 21


Graphs
Definition:
A graph G = (V, E) consists of V, a nonempty set of vertices (or
nodes) and E, a set of edges. Each edge has either one or two
vertices associated with it, called its endpoints. An edge is said to
connect its endpoints.

A computer network
Loops
Definition:
Edges that connect a vertex to itself are called loops.

A graph with loops


Adjacent Vertices
Definition:

When (u, v) is an edge of the graph G with directed edges, u is


said to be adjacent to v and v is said to be adjacent from u.
The vertex u is called the initial vertex of (u, v), and v is called
the terminal or end vertex of (u, v).
The initial vertex and terminal vertex of a loop are the same.

edge(u,v)

u v
The Neighborhood of a Vertex
Definition:
The set of all neighbors of a vertex v of G = (V, E), denoted by
N(v), is called the neighborhood of v. If A is a subset of V, we
denote by N(A) the set of all vertices in G that are adjacent
to at least one vertex in A. So, N(A) = ⋃v∈A N(v).

N(a) = {b, f }
N(b) = {a, c, e, f }
N(c) = {b, d, e, f }
N(d) = {c}
N(e) = {b, c, f }
N( f) = {a, b, c, e}
N(g) = ∅.
Degree of a vertex
Definition 3:
The degree of a vertex in an undirected graph is the number
of edges incident with it, except that a loop at a vertex
contributes twice to the degree of that vertex.
The degree of the vertex v is denoted by deg(v).

deg(a) = 2
deg(b) = 4
deg(c) = 4
deg(d) = 1
deg(e) = 3
deg(f ) = 4
deg(g) = 0.
In-degree and Out-degree of
a Vertex (1)
Definition:
In a graph with directed edges the in-degree of a vertex v,
denoted by deg−(v), is the number of edges with v as their
terminal vertex.
The out-degree of v, denoted by deg+(v), is the number of
edges with v as their initial vertex.
(Note that a loop at a vertex contributes 1 to both the in-degree
and the out-degree of this vertex.).
In-degree and Out-degree
of a Vertex (2)
Example :
Find the in-degree and out-degree of each vertex in the graph G
with directed edges shown in the following Figure?
Number of vertices = 6
Number of edges = 12

deg−(a) = 2 deg+(a) = 4
deg−(b) = 2 deg+(b) = 1
deg−(c) = 3 deg+(c) = 2
deg−(d) = 2 deg+(d) = 2
deg−(e) = 3 deg+(e) = 3
deg−(f) = 0 deg+(f) = 0
In-degree and Out-degree of
a Vertex (3)
Theorem :
Let G = (V, E) be a graph with directed edges. Then
Directed graphs
Definition:
A directed graph (or digraph) (V, E) consists of a nonempty
set of vertices V and a set of directed edges (or arcs) E. Each
directed edge is associated with an ordered pair of vertices.
The directed edge associated with the ordered pair (u, v) is
said to start at u and end at v.

A communications network with one-way communications links.


Undirected Graphs
Undirected edges
Simple Graphs
Definition:
A graph in which each edge connects two different vertices and
where no two edges connect the same pair of vertices is called
a simple graph
Simple Directed Graphs
When a directed graph has no loops and has no multiple
directed edges, it is called a simple directed graph

A computer network with multiple one-way links


Multigraphs

Graphs that may have multiple edges connecting


the same vertices are called multigraphs.

A computer network with multiple links


Mixed Graphs
• For some models we may need a graph where some
edges are undirected, while others are directed.
• A graph with both directed and undirected edges is
called a mixed graph

Mixed Graph
Directed Multigraphs
Directed graphs that may have multiple directed edges
from a vertex to a second (possibly the same) vertex are
used to model such networks.

A computer network with multiple one-way links

You might also like