Graph Definition
Graph Definition
Bibliography:
[CLRS]- Subchap 22.1 – Representation of Graphs
Graphs (part1)
• Basic concepts
• Graph representation
Graphs
• A graph G = (V, E)
– V = set of vertices
– E = set of edges = subset of V V
– |E| <= |V|2
Directed/undirected graphs
• In an undirected graph:
– Edge (u,v) E implies that also edge (v,u) E
– Example: road networks between cities
• In a directed graph:
– Edge (u,v) E does not imply edge (v,u) E
– Example: street networks in downtown
Directed/undirected graphs
Directed graph Undirected graph
In-degree=2 degree=3
Out-degre=1
• Degree of a vertex v:
– The number of edges adjacenct to v
– For directed graphs: in-degree and out-degree
Weighted/unweighted graphs
• In a weighted graph, each edge has an
associated weight (numerical value)
Connected/disconnected graphs
• An undirected graph is a connected graph if
there is a path between any two vertices
• A directed graph is strongly connected if there is
a directed path between any two vertices
Dense/sparse graphs
• Graphs are dense when the number of edges is
close to the maximum possible, |V|2
• Graphs are sparse when the number of edges is
small (no clear threshold)