Graphs: Terminology and Definitions Flashcards
What is graph?
A graph is a mathematical structure consisting of two types of elements
• G = (V,E) where
– V is a set of nodes called vertices
——>The order of a graph is the number of its vertices, i.e. |V|
– E is a collection of edges that connect pairs of vertices
——-> The size of a graph is the number of its edges, i.e. |E|
Edge Types
Directed Edge: – Ordered pair of vertices (u,v) – First vertex u is the origin – Second vertex v is the destination EX: u -------> v
Undirected Edge:
– Unordered pair of vertices (u,v)
EX: u ——– v
A graph may be:
– Undirected, i.e. there is no distinction between two vertices associated with each edge
EX: edge (3,2) is the same as edge (2,3)
()Directed, i.e. the edges are directed from one vertex to the other
EX: edge (1,2) goes from node 1 to node 2,
1 –> 2
Edge components (information)
- Edges may be labeled
- They may have weights, costs, color associated with it
Weighted Undirected graph
EX: a network of airports
Weighted graph
It has weights associated with the edges. Numerical weights are sometimes referred to as cost
Why and when to use graphs over trees?
- Tree can be considered a limited type of graph
- Trees are useful for describing hierarchical information, but they can only describe information where the parent/child relationship is upheld
- To describe information that doesn’t meet this criteria we use graphs
Endpoints (or end vertices) of an edge
Two or more edges having a vertex v as at least one of their endpoints are called edges incident to v
EX: (6, 10), (4,10)
Adjacent vertices
Two vertices connected by an edge are adjacent
Degree of a vertex
It is the number of edges starting or ending at that vertex
Degree in directed graphs
Out-degree: number of edges starting at that vertex
In-degree: number of edges ending at that vertex
A path
A sequence of edges (or of adjacent vertices)
The length of a path
The number of edges on that path
A simple path
A path where all its vertices and edges are distinct
A cycle
A path beginning and ending at the same vertex
A simple cycle
A cycle which does not pass through any vertex more than once
A loop
An edge whose endpoints are the same vertex