شابتر 9
graph G =(V, E) where:
الرؤوس
(V: set of vertices (nodes
االضالع
E: set of edges.
F: is a function that maps set of edges E to set of ordered or unordered pairs of elements V.
هي العملية التي تحدد نوع العالقة بين الرؤوس سواء كانت مرتبة او غير مرتبه
)}Ex: G =({1,2, 3}, {e1, e2, e3
} ))F = {(e1,(1,2) ), (e2,(2,3)), (e3,( 3,1
يعني رح نمثلها بغطالق سهم من 1الى 2ومن 2الى 3ومن 3الى ......... 1بالترتيب
انواع التمثيل
Types of Graphs:
1. Simple Graphs
يحتوي على :
عدة رؤوس .
عدة اضلع او روابط "غير" موجّهه تنطلق من رأس آلخر دون تكرار .
2. Multigraphs
يحتوي على :
نفس محتويات الرسم البياني البسيط ،باالضافة الى ان هناكـ اكثر من ضلع يربط الرؤوس ببعضها البعض .
G=(V, E, f ) consists of a set V of vertices, a set E of edges and a function f:E{{u,v}|u,vV uv}.
(The edges e1 and e2 are called multiple (parallel( edges if f (e1) = f (e2
3. Pseudographs
يحتوي على :
خصائص الرسم المتعدد ،باالضافة الى وجود الـ loopاي ان كل رأس يرتبط بنفسه .
G=(V, E, f ) where f : E{{u,v}|u,vV} , Edge e E is a loop if f(e)={u,u}={u}.
4.Directed Graphs
يحتوي على :
روابط موجّهه ،اي ان الروابط تنطلق بترتيب معين ...كما يسمح بوجود الـ . loop
ال يسمح بوجود الروابط المتعددة .
5. Directed Multigraphs
: يحتوي على
. باالضافة الى انه يسمح بوجود روابط متعدده بين الرؤوس، نفس خصائص الرسم الموجّه
G=(V, E, f ) consists of a set V of vertices, a set E of edges, and a function f: E V V.
::..Graph Terminology..::
Undirected Graph: Adjacency
Let G be an undirected graph with edge set E. Let e E where e = {u,v}. Then we say:
u, v are adjacent / neighbors / connected.
Edge e is incident with vertices u and v.
Edge e connects u and v.
Vertices u and v are endpoints of edge e.
Undirected Graph: Degree of a Vertex
Let G be an undirected graph, vV a vertex.
The degree of v, deg(v), is its number of incident edges. (Except that any self-loops are counted twice.)
. درجة التمثيل هي عدد الروابط الصادرة من والى الرؤوس دون تكرار: اذن
A vertex with degree 0 is isolated.
A vertex of degree 1 is pendant.
: هذا قانون لحساب درجة التمثيل غير الموجّه
deg( v) 2e
vV
E = edges
V= vertex
2 X درجة التمثيل تساوي مجموع عدد الرؤوس = عدد االضالع المعاطاة، اذن
How many edges are there in a graph with ten vertices each of degree 6 ?
Solution:
Sum of the degrees of the vertices 6 .
10 + 10 + 10 + …… 6 times =60
Therefore:
deg( v) 2e
vV
60 = 2e <<<<<<<<<<<<
Such as equalizing
Then : e = 30
Other Ex :
Deg(a)= 6
Deg(b)= 4
Deg(c)= 1 <<<<< pendant
Deg(d)= 0 <<<<< isolated
عندما ال يوجد سوى لينك واحد فقط ينطلق من الرأس تسمى
عندما ال يوجد اي لينك ينطلق من الرأس تسمى
Deg(e)= 3
Deg(f)= 4
Deg(g)= 2
And so on .
Directed Graph: Adjacency
Let G be a directed (possibly multi-) graph, and let e be an edge of G that is (u, v). Then we say:
u
v
–
u is adjacent to v, v is adjacent from u
–
e comes from u, e goes to v.
–
e connects u to v, e goes from u to v
–
the initial vertex of e is u
–
the terminal vertex of e is v
Directed Graph: Degree of a vertex
Let G be a directed graph, v a vertex of G.
–
The in-degree of v [ deg(v) ] , is the number of edges going to v.( v is terminal)
–
The out-degree of v [ deg(v) ] , is the number of edges coming from v. (v is initial)
V الواردة هي عدد الللينك التي جاتء الىV درجة: اذن
V الصادرة هي عدد اللينك التي صدرت منV درجة: بينما
–
The degree of v, deg(v) deg(v)+deg(v)
–
A loop at a vertex contributes 1 to both in-degree and out-degree of this vertex
<<<<<
عن طريق جمع7 يمكننا حساب درجة الـ
: قوانين ايجاد درجة الرسوم البيانية الموجّهه
deg
vV
(v )
deg
(v )
vV
1
deg( v) E
2 vV
: طريقه استخدام القانون
. نوجد عدد كل من الروابط الصادرة من الرؤوس ثم نجمعها.1
. نوجد كل من الروابط الواردة الى الرؤوس ثم نجمعها.2
2 ثم نقسم على2 + 1 نجمع.3
: مثال
Special Graph Structures
Special cases of undirected graph structures:
Complete graphs Kn
For any nN, a complete graph on n vertices Kn is: a simple graph with "n" nodes in which every node is
adjacent to every other node: u,vV: uv{u,v}E.
Cycles Cn
For any n3, a cycle on n vertices, Cn, is a simple graph where V={v1,v2,… ,vn} and E={{v1,v2},{v2,v3},…,{vn
1,vn},{vn,v1}}.
Wheels Wn
For any n3, a wheel Wn, is a simple graph obtained by taking the cycle Cn and adding one extra vertex vhub and
n extra edges {{vhub,v1}, {vhub,v2},…,{vhub,vn}}.
n-Cubes Qn
For any nN, the hypercube Qn is a simple graph consisting of two copies of Qn-1 connected together at
corresponding nodes. Q0 has 1 node.
Graph representations:
Adjacency lists.
–
Adjacency matrices.
–
Undirected graph: Adjacency Lists
يعني في الرسم البياني "غير" الموجّه ،نشوف كل رأس ارتبطت بمين وندونها في جدول كما هو موضح ادناه (من الرسم)
Adjacent
Vertex Vertices
a
b, c
b
a, c, e, f
c
a, b, f
d
e
b
f
c, b
وفي حال اعطانا الجدول وطلب الرسم ،كل ما علينا هو وضع الرؤوس Vertexثن ارسال اسهم موجّهه كما هو مطلوب .
Undirected graph : Adjacency Matrices
في الرسم غير الموجّه وباستخدام الرسم ،يمكننا ايجاد مصفوفة للرسم البياني وذلك بالطريقة التالية :
بين قوسين المصفوفه ،نصف جميع رؤوس الرسم البياني مشكلين بها اعمدة ،وكذلك نشكل بها صفوف.
في حال وجود عالقة بين الرأس وأخر نمثل ذلك بعدد االسهم الموجّه من الرأس لألخر (يعني لو عندنا سهم نكتب – 1لو عندنا 4اسهم نكتب 4
في المصفوفة وهكذا )......
في حال لم يوجد نمثل العالقة بالعدد( )0
d e
b c
1 1 0 0
0 1 0 1
1 0 0 0
0 0 0 0
1 0 0 0
A
a 0
b 1
c 1
d 0
e 0
والعكس صحيح ،في حال اعطانا الماتركس وطلب مننا الرسم ،فهد نرسم اسهم من والى الرؤوس المطلوبة .
Directed Adjacency Lists:
هنا يجب معرفة نقطة البداية ، Initial vertexونقطة النهاية Terminal vertices
ونمثلها في الجدول حسب الرسم
Terminal
vertices
Initial
vertex
V2, V4, V5
V1
V4
V2
v5
V3
V4
v2
0
0
0
0
0
0
1
1
0
0
0
0
0
1
0
0
0
0
0
1
a 0
b
0
c 0
d 0
e
0
V5
Isomorphic simple graphs must have the same:
نفس عدد الرؤوس
-
Number of vertices
-
Number of edges
-
Degrees of vertices are the same: deg(v) in graph G ≡ deg(F(v )) in graph H
نفس عدد اللينكـ
U1
نفس الدرجة
u2
U3
u4
The function f : f(u1)=v1,f(u2)=v4,f(u3)=v3,f(u4)=v2
So ,
..... ونعيد رسم القراف حسب المساوة اللى في الفنكشن فقطV بـU المطلوب من الفنكشن اننا نبدل
Connectivity
a path of length n from u to v is a sequence of adjacent edges going from vertex u to vertex v.
. هو سلسلة من اللينك المجاورة لبعضها بداية من رأس معين الى رأس االخر: يعرف الطريق في الرسم غير الموجّه
A path is a circuit if u=v.
. u=v يكون الطريق دائرة في حال
A path is simple if it contains no edge more than once.
. الطريق البسيط ال يحتوي على اكثر من لينك واحد فقط
: مثال
•
Simple path: a, d, c, f, e …………………. the edges are {a,d},{d,c},c,f},{f,e} ……………. length=4
•
Circuit: b ,c,f,e,b ………………
•
Not path : d,e,c,a …………………. because {e,c} is not an edge
•
Not simple path: a,b,e,d,a,b because {a,b} appears twice ………….. length =5
the edges are {b,c},{c,f}, {f,e},{e,b} …….. length =4 الدائرة تعني انه رسم مغلق
Paths in Directed Graphs :
. ) باالضافة الى تحديد اتجاه السم فقط (من وين يبدأ و وين ينتهي، يتم تحديدها مثل الرسم غير الموجّه
An undirected graph is called connected if there is a path between every pair of distinct vertices of the graph.
. نقول عن رسم غير موجّه انه متصل او مرتبط في حال ان جميع الرؤوس االساسية بالرسم متصلة ببعضها
: مثال
a
b
d
e
connected graph
not connected graph
c
Connected Components :
connected components of the graph: is that graph has not connected is the union of two or more connected
subgraphs with no vertices in common.
connected components of the graph : يسمىsub-graph الرسم البياني الذي ال يرتبط بـ اثنين او اكثر من
A directed graph is strongly connected if there is a path from a to b and from b to a whenever a and b are
vertices in the graph.
)يكون الترابط قوي في حال انه حافظ على الترتيب بين الروابط (يعني تبدأ من نقطة معينة وتستمر بنفس االتجاه حتى تنتهي عند النقطة نفسها
a
d
b
c
A directed graph is weakly connected if there is a path between every two vertices when the direction of
edges are disregarded.
) يكون الترابط ضعيف في حال انه لم حافظ على الترتيب بين الروابط (يعني تبدأ من نقطة معينة وال تستمر بنفس االتجاه
a
c
b
d
© Copyright 2026 Paperzz