Combinatorial Optimisation Flashcards
We say that two vertices x and y are adjacent if
There is an edge connecting x and y
The degree of a vertex x is
the number of vertices adjacent to x
Handshaking lemma:
sum(deg(x)) = 2 |E|
^ |E| is the number of edges, I think
Adjacency matrix
A matrix with an entry 1 if x and y are adjacent and 0 otherwise.
Adjacency list
For each vertex i we keep an ordered list of its neighbours
The number of steps taken to check if two vertices are adjacent for a:
- adjacency matrix
- adjacency list
- matrix: n^2
- list: 2m
(n is number of vertices; m is number of edges)
We prefer an adjacency matrix when…
The graph is dense
If there is not a path between two vertices then we say that the distance between them is…
…infinite.
In order to find the connected components of a tree we use…
a breadth-first search.
A property of BFS trees
If xy is an edge of G not belonging to the BFS tree then either x and y are in consecutive layers or in the same layer.
Breadth-First Search
Start at some point s. Then define each layer L[i] as the set of vertices adjacent to some vertex in L[i-1] that are not already in the BFS tree.
Theorem: a graph is bipartite if and only if
it contains no odd cycle
Algorithm for testing bipartiteness
Run BFS.
Let R be the union of odd layers and B be the union of even layers.
If there are no edges connecting two red vertices or two blue vertices, the graph is bipartite.
A greedy algorithm
is one which makes locally optimal choices in the hope of finding a globally optimal choice.
Prim’s algorithm for finding an MST
Pick a vertex to start with s, and make s an element of T.
Of all the edges that connect T to vertices not in T, pick the one with the lowest weight.
Output T.