Graphs Flashcards
A _________________ is a pair V, E ,where V is a finite set and E is a binary relation on V.
directed graph
TRUE or FALSE:
Edges from a vertex to itself (self- loops) are possible in a undirected graph.
FALSE. Only possible for directed graphs
u -> v
u, v is incident from u and is incident to v.
u -> v
v is adjacent to u.
TRUE or FALSE:
In an undirected graph G = V, E , E
consists of unordered pairs of vertices.
TRUE
u - v
u, v is incident on u and v.
u - v
u is adjacent to v and
v is adjacent to u.
In an undirected graph, the ________ of
a vertex is the ________________
incident on it.
degree, number of edges
In a directed graph:
the ____________of a vertex is the
number of edges leaving it
the _____________ of a vertex is the number
of edges entering it
out-degree, in-degree
In a directed graph:
the degree of a vertex is the _____ of its in-degree and its out-degree
sum
A ______ from a vertex v0 to a vertex vk is a sequence of vertices
path
The _____________ of a path is the number of edges in the path.
length
A path is _________ if all vertices in the path are distinct.
simple
Graph Representation using adjacency matrix
row is source
column is destination
TRUE or FALSE:
In an undirected graph, the adjacency
matrix A is its own transpose: A = AT.
TRUE
An array Adj of V lists, one for each
vertex in V.
Adj[u] consists of all the vertices adjacent to u in G.
Adjacency List
Running time of operations:
Check if vertex u is adjacent to vertex v
Adj Mat - O(1)
Adj List - O(V)
Running time of operations:
List all vertices that
are adjacent to u
Adj Mat - O(|V|)
Adj List - O(|V|)
Running time of operations:
List all edges of G
Adj Mat - O(|V^2|)
Adj List - O(|V| + |E|)
Adjacency lists provide a compact way to represent _____________
i.e. E significantly less than V2
sparse graphs