Sift on - دانشگاه شاهرود

Download Report

Transcript Sift on - دانشگاه شاهرود

‫ساختمانهای گسسته‬
‫سید محمد مهدی صالحی‬
‫( دانشکده کامپیوتر و فناوری اطالعات‪ ،‬دانشگاه صنعتی شاهرود )‬
Introduction
• Because many situations and structures give rise to
graphs, graph theory has become an important
mathematical tool in a wide variety of subjects,
ranging from operations research, computing
science and linguistics to chemistry and genetics.
• Recently, there has been considerable interest in tree
structures arising in computer science and artificial
intelligence. We often organize data in a computer
memory store or the flow of information through a
system in tree structure form. Indeed, many
computer operating systems are designed to be tree
structures.
2
What is a graph?
• Graphs represent the relationships among data
items
• A graph G consists of
– a set V of nodes (vertices)
– a set E of edges: each edge connects two nodes
• Each node represents an item
• Each edge represents the relationship between
two items
node
edge
2015/7/16
CS201
3
What is a Graph
P
Q
R
S
T
P
Q
electrical network
R
P
Q
T
S
R
T
S
road map
Diagrammatic Representation
4
Labeling
friend
Movie 1
co-worker
Mary
Peter
brothers
friend
Albert
Movie 3
Actor 4
Movie 2
Albert
Protein 1
Actor 2
Actor 1
Actor 3
Protein 2
Protein 5
Protein 9
Network Science: Graph Theory
2012
Examples of graphs
Computer Network
Molecular Structure
H
H
C
Server 1
Terminal 1
H
Terminal 2
H
Server 2
Other examples: electrical and communication networks,
airline routes, flow chart, graphs for planning projects
2015/7/16
CS201
6
2015/7/16
CS201
7
2015/7/16
CS201
8
THE BRIDGES OF KONIGSBERG
Can one walk across the
seven bridges and never
cross the same bridge
twice?
Network Science: Graph Theory
2012
Königsberg bridges problem
The four places (A, B, C and D) in the city of Königsberg were
interconnected by seven bridges (p, q, r, s, t, u and v) as shown
in the following diagram. Is it possible to find a route crossing
each bridge exactly once ?
Königsberg C
v
s
r
D
A
p
t
q
B
u
10
Formal Definition of graph
• The set of nodes is denoted as V
• For any nodes u and v, if u and v are
connected by an edge, such edge is denoted
as (u, v)
v
(u, v)
u
• The set of edges is denoted as E
• A graph G is defined as a pair (V, E)
2015/7/16
CS201
11
Example (Undirected Graph)
z
u
vertex-set V(G) = {u, v, w, z}
e2
e1
e4
edge-set E(G) = {e1, e2, e3, e4}
v
e3
w
edge-endpoint function
Edge
Endpoints
e1
e2
e3
e4
{u, v} {u, w} {v, w} {w, z}
12
13
Adjacent
• Two nodes u and v are said to be adjacent
if (u, v)  E
v
(u, v)
u and v are adjacent
v and w are not adjacent
2015/7/16
CS201
u
w
14
Multigraph
• Multigraph allows multiple edges and self
edge (or loop).
Multiple edge
Self edge
2015/7/16
CS201
15
Subgraph
• A subgraph of a graph G =(V, E) is a
graph H = (U, F) such that U  V and
F  E.
v2
v1
v3
v5
v4
v3
v5
v4
H
G
2015/7/16
v2
CS201
16
Multiple edges , Loop and Degree
• Two or more edges joining the same pair of
vertices are called multiple edges
• and an edge joining a vertex to itself is called a
loop.
• The degree of a vertex is the number of edges
meeting at a given vertex.
17
Example (Multiple edges , Loop and Degree)
w
e2
e1
u
z
e3
e5
e6
e7
V(G) = {u, v, w, z}
E(G) = {e1, e2, e3, e4, e5, e6, e7}
e4
deg u = 6, deg v = 5,
deg w = 2, deg z = 1
v
total degree = 6 + 5 + 2 + 1 = 14
Multiple
edges
loop
edge-endpoint function
Edge
Edge points
e1
{u, u}
e2
{u, w}
e3
{v, w}
e4
{v, z}
e5
{u, v}
e6
{u, v}
e7
{u, v}
18
Walk
v3
v6
e2
v4
e1
v1
e6
e3
v2
e4
e7
e5
v7
v8
v5
• A walk of length k between v1 and v8 in a graph G is a
succession of k edges of G of the form v1e1v2, v2e2v3, v3e3v4, …
,v7e7v8.
• We denote this walk by v1e1v2e2v3e3v4e4v5e5v6e6v7e7v8.
19
• If all the edges (but not necessarily all the
vertices) of a walk are different, then the walk is
called a trail.
• If , in addition, all the vertices are different, then
the walk is called path.
20
Examples
v1
v3
v1
v3
v5
v2
v4
v1 v2 v4 v1 v3 v5 is a trail
v5
v2
v4
v1 v2 v4 v3 v5 is a path
21
• Closed walk: in a walk, first and last vertices are
the same.
• A cycle is a closed path with at least 3 distinct
edges.(source node and destination node are the same.)
22
Example
v1
v1
v3
v3
v5
v5
v2
v4
v1 v2 v4 v3 v5 v4 v1 is a closed walk
v2
v4
v1 v2 v4 v5 v3 v1 is a cycle
23
Connected graph
• A graph G is connected if there exists path
between every pair of distinct nodes;
otherwise, it is disconnected
v2
v3
v1
v5
v4
This is a connected graph because there exists path
between every pair of nodes
2015/7/16
CS201
24
Example of disconnected graph
v7
v3
v1
v8
v2
v4
v5
v6
v9
This is a disconnected graph because there does not
exist path between some pair of nodes, says, v1 and v7
2015/7/16
CS201
25
Connected component
• If a graph is disconnect, it can be partitioned into
a number of graphs such that each of them is
connected. Each such graph is called a
connected component.
v2
v1
v4
2015/7/16
v7
v3
v5
CS201
v6
v8
v9
26
Connected and Disconnected Graphs
Connected Graph
components
• A graph G is
connected if there is a
path in G between any
given pair of vertices,
and disconnected
otherwise.
Disconnected Graph
27
Weighted graph
• If each edge in G is assigned a weight, it is
called a weighted graph
Chicago
New York
1000
3500
2000
Houston
2015/7/16
CS201
28
Directed Graph
A directed graph G consists of vertices, and a set
of edges, where each edge is associated with a list
of ordered pair endpoints
29
Example (Directed Graph)
z
u
vertex-set V(G) = {u, v, w, z}
e2
e1
e4
edge-set E(G) = {e1, e2, e3, e4}
v
e3
w
edge-endpoint function
Edge
Endpoints
e1
e2
e3
e4
(u, v) (w, u) (w, v) (z, w)
30
UNDIRECTED VS. DIRECTED NETWORKS
Undirected
Directed
Links: undirected (symmetrical)
Links: directed (arcs).
Graph:
Digraph = directed graph:
L
A
M
F
D
B
An undirected
link is the
superposition of
two opposite
directed links.
C
I
D
G
B
E
G
H
A
C
Undirected links :
coauthorship links
Actor network
protein interactions
F
Directed links :
URLs on the www
phone calls
metabolic reactions
Network Science: Graph Theory January 24, 2011
32
34