1.0 - Graphs
Graphs are comprised of vertices and edges.
- Vertices
- Edges
Could be used to represent different types of information
- Geographical information (Vertices = cities, Edges = roads)
- Networks (Vertices = computers, Edges = cables)
- Brains (Vertices = neurons, Edges = synapses)
- Programs (Vertices = statements, Edges = control flow)
1.1 - Directed or Undirected Graphs
1.1.1 - Undirected Graphs
- Cannot have self-loops
- If , is
adjacent
to u in G (and u isadjacent
to v) - symmetric property - Edge is
incident
on vertices
1.1.2 - Directed Graphs
- Can have self-loops
- If , is adjacent to - asymmetric property
- Edge is incident from (leaves) vertex and incident on (enters) vertex
- The out-degree of a vertex is the number of edges leaving it
- The in-degree of a vertex v is the number of edges entering it
- The degree of a vertex is the sum of its in-degree and out-degree.
- Maximum number of edges
1.2 - Weighted or Unweighted Graphs
1.2.1 - Unweighted Graphs
- A graph in which edges don’t have weights associated with them
1.2.2 - Weighted Graph
- A graph in which each edge has a weight associated with it.
1.3 - Paths
For a graph
- A
path
of length from a vertex to a vertex is a sequence of vertices such that for- That is, every two consecutive vertices form an edge that is in the graph.
- is
reachable
from if there is path from to - A path is
simple
if all of the vertices i nthe path are distinct - A path forms a
cycle
if and - A cycle is
simple
if are distinct, and all of its edges are distinct - A graph with no simple cycles is
acyclic
1.4 - Undirected Graphs - More Properties
- An undirected graph is connected if every vertex is reachable from all vertices
-
An undirected graph is connected if every vertex is reachable from all other vertices
-
An undirected graph is a forest if it is acyclic
-
An undirected graph is a tree if it is a forest (i.e. acyclic) with only one connected component.
-
What are the minimum and maximum number of edges in a:
- Tree with vertices?
- Forest with vertices?
- Doesn’t have to be connected, so minimum is 0
- Connected graph with vertices?
1.5 - Directed Graphs - More Properties
A directed graph is:
- Strongly connected if every two vertices are reachable from each other
1.6 - Graph Terminology
-
Graph is a sub-graph of when and
-
is a spanning sub-graph of if the above, and also holds.
-
The sub-graph of that is induced by is the graph where: