0% found this document useful (0 votes)
48 views9 pages

Harolds Undirected Graphs and Trees Cheat Sheet 2022

Uploaded by

abooie
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views9 pages

Harolds Undirected Graphs and Trees Cheat Sheet 2022

Uploaded by

abooie
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Harold’s Undirected Graphs and Trees

Cheat Sheet
22 October 2022

Definitions

Term Definition Example


Vertices An individual element of V is called a vertex. Set 𝑉 = {𝑎, 𝑏, 𝑐, 𝑑, 𝑒}
(Nodes) A graph is finite if the vertex set is finite. ① or ●
Set E ⊆ V x V
𝐸 = {{𝑎, 𝑏}, {𝑎, 𝑐}, . . . , {𝑑, 𝑒}}

Edges An edge (u, v) ∈ E, is pictured as an arrow


(Arcs) going from one vertex to another.

Self-Loop
An edge that connects a vertex to itself.
(Loop)

G = (V, E)

Undirected A graph whose edges are unordered pairs of


Graph vertices.

Simple Graph A graph with no parallel edges or self-loops. |Cycle| ≥ 3


Adjacent There is an edge between two vertices. Two vertices are connected.
Vertices b and e are the endpoints of edge
Endpoints The two vertices of an edge.
{b, e}
The edge {b, e} is incident to vertices b and
Incident The edge of two vertices.
e.
A vertex c is a neighbor of vertex b if and
Neighbor Has an edge to it.
only if {b, c} is an edge.
The degree of a vertex is the number of
Degree 𝑑𝑒𝑔(𝑣)
neighbors it has.
Total Degree The sum of the degrees of all of the vertices. ∑ 𝑑𝑒𝑔(𝑣) = 2 · |𝐸|
𝑣∈𝑉
Regular Graph All the vertices have the same degree. 𝑑𝑒𝑔(𝑎) = 𝑑𝑒𝑔(𝑏) = 𝑑𝑒𝑔(𝑐) . ..

Copyright © 2022 by Harold Toomey, WyzAnt Tutor 1


3-Regular Graph:

d-Regular
All the vertices have degree d.
Graph

2-Regular Graph:

A graph H = (VH, EH) is a subgraph of a graph


Subgraph G = (VG, EG) if VH ⊆ VG and EH ⊆ EG.
Any graph G is a subgraph of itself.

K6: Complete Graph (Clique)


C7: Cycle

Has an edge between every pair of vertices.


K3,4:
Q3: 3-Dimentional Hypercube

Common
Graphs

Has 2n vertices. No edges between vertices in


the same set.
S5: Star

P5: A path

Copyright © 2022 by Harold Toomey, WyzAnt Tutor 2


Graph Representation

Term Description
Each vertex has a list of all its neighbors.

Adjacency List

A ‘1’ means an edge is present. Is symmetrical about the diagonal


(Mi,j = Mj,i).

Matrix

There is a one-to-one correspondence between each of the edges of


Isomorphic
two graphs (bijection).
"Efficient" Algorithm An algorithm that runs in worst-case polynomial time.
Consider two graphs, G and G'. Let f be an isomorphism from G to G'.
For each vertex v in G, the degree of vertex v in G is equal to the
Theorem: Vertex degree degree of vertex f(v) in G'.
preserved under
isomorphism
If one graph has a vertex of degree 1 and the other graph does not,
then not isomorphic.
Degree Sequence A list of the degrees of all of the vertices in non-increasing order.

Copyright © 2022 by Harold Toomey, WyzAnt Tutor 3


Theorem: Degree
Degree sequence is preserved under isomorphism.
sequence preserved under
If two graphs are isomorphic, they have the same degree sequence.
isomorphism
Concerned with properties of graphs that are preserved under
isomorphism.

Preserved:
• Number of vertices (|V|)
• Number of edges (|E|)
Graph Theory
• Degree sequence (degrees listed high to low)
• Total degree (2·|E|)

Not Preserved:
• The lowest numbered vertex has degree 3
• Every even numbered vertex has odd degree

Graph Types

Term Description Example


〈𝑣0 , (𝑣0 , 𝑣1 ), 𝑣1 , (𝑣1 , 𝑣2 )𝑣2 , . . . , 𝑣𝑙 〉
A sequence of alternating vertices and edges
Walk 〈𝑣0 , 𝑣1 , 𝑣2 , . . . , 𝑣𝑙 〉
that starts and ends with a vertex.
| 〈𝑣0 〉 | = 0
A walk in which the first and last vertices are
Open Walk 〈𝑎, . . . , 𝑧〉
not the same.
A walk in which the first and last vertices are
Closed Walk 〈𝑎, . . . , 𝑎〉
the same.
l, the number of edges in the walk, path, or 𝑙 = |𝐸|
Length
cycle. 𝑙 = |𝑉| − 1 if sequence
An open walk in which no edge occurs more
Trail 〈𝑎, 𝑏, 𝑐, 𝑑, 𝑐, 𝑏, 𝑎〉
than once.
A closed walk in which no edge occurs more
Circuit 〈𝑎, 𝑏, 𝑎, 𝑐, 𝑎〉
than once.
A trail in which no vertex occurs more than
Path 〈𝑎, 𝑏, 𝑐, 𝑑〉
once.
A circuit of length at least 1 in which no
Cycle vertex occurs more than once, except the 〈𝑎, 𝑏, 𝑐, 𝑎〉
first and last vertices which are the same.

No repeated …
Walk
Edge Vertex or Edge
Open Trail Path
Closed Circuit Cycle

Copyright © 2022 by Harold Toomey, WyzAnt Tutor 4


Connectivity

Term Description Example


If there is a path from vertex v to vertex
w, then there is also a path from w to v.
Connected
The two vertices, v and w, are said to be
connected.
A graph is said to be connected if every
pair of vertices in the graph is
Disconnected
connected, and is disconnected
otherwise.
Connected A maximal set of vertices that is
See graph above for examples.
Component connected.
A vertex that is not connected with any
other vertex is called an isolated vertex
Isolated Vertex ●
and is therefore a connected component
with only one vertex.
2-vertex-connected:

The graph contains at least k + 1 vertices


and remains connected after any k - 1
k-Vertex-Connected
vertices are removed from the graph.
(mesh network)

The largest k such that the graph is k- κ(G)


Vertex Connectivity
vertex-connected. 𝜅(𝐾𝑛 ) = 𝑛 − 1
3-edge-conncted:

The graph remains connected after any


k-Edge-Connected
k - 1 edges are removed from the graph.

The largest k such that the graph is k- λ(G)


Edge Connectivity
edge-connected. λ(𝐾𝑛 ) = 𝑛 − 1
Let G be an undirected graph. Denote The minimum degree of any
Theorem: Upper
the minimum degree of any vertex in G vertex is at least an upper
bound for vertex and
by δ(G). Then κ(G) ≤ δ(G) and λ(G) ≤ bound for both the edge and
edge connectivity
δ(G). vertex connectivity of a graph.
There is no set of vertices whose
Complete Graph Full mesh network.
removal disconnects the graph.

Copyright © 2022 by Harold Toomey, WyzAnt Tutor 5


Euler Circuits and Trails

Term Description Example


An undirected graph circuit that contains
every edge and every vertex.
Euler Circuit
Every vertex reached.
Every edge occurs exactly once.
Theorem: Required If an undirected graph G has an Euler
𝑑𝑒𝑔(𝑣) = 2𝑘
conditions for an Euler circuit, then G is 1) connected and 2) every
where 𝑘 ∈ ℤ+
circuit in a graph vertex in G has an even degree.
Theorem: Sufficient
If an undirected graph G is connected and every vertex in G has an
conditions for an Euler
even degree, then G has an Euler circuit.
circuit in a graph
Theorem:
Characterization of An undirected graph G has an Euler circuit if and only if G is
graphs that have an Euler connected and every vertex in G has even degree.
circuit
Find circuit C in G.
Repeat until C is an Euler circuit:
Create new graph G' :
Remove edges in C from G
Remove isolated vertices
Find vertex w in G' and C (select any)
Procedure
Find circuit C' in G' starting at w
Combine C and C'
Follow edges in C to w
Follow edges in C' back to w
Follow remaining edges in C
Rename new circuit to be C

An undirected graph open trail that


Euler Trail
includes each edge exactly once.

Theorem:
An undirected graph G has an Euler trail if Euler trail begins and
Characterizations of
and only if G is 1) connected and 2) has ends with vertices of
graphs that have an Euler
exactly two vertices with odd degree. odd degree.
trail

Copyright © 2022 by Harold Toomey, WyzAnt Tutor 6


Tree Terms

Term Description Example


An undirected graph that is connected and
Tree Computer file system
has no cycles.

There is no particular organization of the


Free Tree
vertices and edges

The vertex at the top is designated as the


Rooted Tree
root of the tree.

The level of a vertex is its distance (number


The root is the only level 0
Level of edges in the shortest path between the
vertex.
two vertices) from the root.
The height of a tree is the highest level of any
Height Most hops to bottom.
vertex.
The first vertex after v encountered along the
Parent The parent of vertex g is h.
path from v to the root. (One vertex above v.)
Vertices c and g are the children
Child The vertex below the parent.
of vertex h.
The ancestors of vertex g are h,
Ancestor All vertices up in path.
d, and b.
The descendants of vertex h are
Descendant All vertices down in path.
c, g, and k.
Rooted: A vertex which has no children. The leaves are a, f, c, k, i, and j.
Leaf
Free: A vertex of degree 1. 𝑑𝑒𝑔(𝑣) = 1
Vertices h, i, and j are siblings of
Sibling Vertices with the same parent.
parent d.
The subtree rooted at h includes
A tree consisting of new root v and all v's
Subtree h, c, g, and k and the edges
descendants.
between them.
Shows all possible playing strategies of both
players in a game.
Game Tree vi = game configuration
Games can be deterministic (tic-tac-toe) or
chance (dice).
Variable The number of bits for each character can
‘a’ = 1, ‘e’ = 01, etc.
Length Codes vary.

Copyright © 2022 by Harold Toomey, WyzAnt Tutor 7


The code for one character cannot be a prefix Leaf nodes guarantee the prefix
Prefix Code
of the code for another character. property.
ASCII 8-Bit characters (256 max.) UTF-8
Unicode 16-Bit characters (64K max.) UTF-16
Internal Vertex Free: The vertex has degree at least two. 𝑑𝑒𝑔(𝑣) ≥ 2
A graph that has no cycles and that is not
Forest necessarily connected.
|E|= |V| – |C| (connected components)

Tree Theorems

Term Description Example

Let T be a tree and let u and v be two vertices


in T. There is exactly one path between u and v.
Theorem: Unique
paths in trees
There is a unique path between every pair of
vertices in a tree.

Theorem: Number of Let T be a tree with n vertices and m edges,


𝑚 =𝑛−1
edges in a tree then m = n - 1.
Lower bound
Theorem: Number of Any free tree with at least two vertices has at
leaves in a tree least two leaves.
Theorem: Prim's Prim's algorithm finds a minimum spanning See Spanning Trees
Algorithm tree of the input weighted graph. below

Tree Traversals

Term Description Example


Traversal Systematically visiting each vertex. Hit a node.
First hit (left side) of
Pre-Order Traversal A vertex is visited before its descendants.
tree vertex
In-Order Traversal A vertex is visited after its first descendant. 2nd hit of tree vertex
Last hit (right side) of
Post-Order Traversal A vertex is visited after its descendants.
tree vertex

Copyright © 2022 by Harold Toomey, WyzAnt Tutor 8


Spanning Trees

Term Description Example


Fewest edges
For a connected graph G. a subgraph of G which
Spanning Tree possible to visit all
contains all the vertices in G and is a tree.
vertices
Depth-First Search Favors going deep into the graph. Explorer ventures far
(DFS) Produces trees with longer paths. away from home
Explores the graph by distance from the initial
Breadth-First Search vertex, starting with its neighbors and expanding Explorer ventures
(BFS) the tree to neighbors of neighbors. close to home
Produces trees with shorter paths.
The function w
A graph G = (V ,E), along with a function w: E →
Weighted Graph assigns a real number
ℝ.
to every edge.

w(G) is the sum of


Weight w(G) the weights of the
edges in G.

Minimum Spanning A spanning tree T of G whose weight is no larger


Goal: Min. weight
Tree (MST) than any other spanning tree of G.
A classic algorithm for finding minimum spanning
Always choose min.
trees developed by mathematician Robert Prim in
edge in queue.
1957.
Input: An undirected, connected, weighted graph G.
Output: T, a minimum spanning tree for G.

T := ∅.
Pick any vertex in G and add it to T.
Prim's Algorithm
For j = 1 to n-1
Let C be the set of edges with one endpoint
inside T and one endpoint outside T.
Let e be a minimum weight edge in C.
Add e to T.
Add the endpoint of e not already in T to T.
End-for

Sources:
• SNHU MAT 230 - Discrete Mathematics, zyBooks.
• See also “Harold’s Directed Graphs Cheat Sheet”.

Copyright © 2022 by Harold Toomey, WyzAnt Tutor 9

You might also like