Directed Graphs Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is a directed cycle and a simple cycle?

A
  • Directed: Path with at least one edge whose first and last vertices are the same
  • Simple: Cycle with no repeated edges / vertices
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the adjacency list representation of the DG?

A

Edge v - w represented as list node containing w in Linked List corresponding to v.Same as undirected graphs however each edge only appears once.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the difference between the adjacency list representation in DG compared to UDG?

A

UDG if v is on w’s list, then w is on v’s list. Digraph has no such symmetry.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does the reverse() method do?

A

Returns copy of digraph with all edges reversed.
Allows clients to find edges that point to each vertex while adj() gives vertices connected by edges pointing from each vertex

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the algorithms for Finding paths and BFS for digraphs?

A

algorithms are fundamental digraph algorithms. Therefore identical.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the single and multiple source reachagbility problem?

A

Given digraph and source s, is there a directed path from s to v?
Is there directed path from any vertex in the set to a given target vertex v?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How are the source reachability problems accounted for?

A
  1. Change of DFS
  2. 2nd constructor for DFS that takes list of vertices
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the time for DFS in a digraph to mark all reachable vertices from a given set of sources?

A

Sum of out degrees that are marked.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is topological sort?

A

Given a graph, put vertices in order such that all its directed from early to late

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How can a DAG be identified?

A

The absense of a directed cycle. Can not sort topologically if cycle is present.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do we identiy a directed cycle?

A

Using DFS.
Stack maintained represents current directed path under consideration.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How is the API for DIrectedCycle implemented?

A
  • Creates integer stack Cycle which contain vertices within cycle
  • ## Adds boolean array onStack[] where integers represent vertices, Boolean values represent their existnce on cycle and for which the recursive call has not completed. onStack for source will be returned to false once all vertices adjacent to it have been searched.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the precedence contstrained scheduling problem?

A

A problem where there are a set of jobs to be completed, constrained to the requisite that certain jobs must be completed before another is completed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do we create an algorithm for topological sort?

A

Save argument vertex to recusrive dfs() in a Data structure.
Iterate through structure. We then see all vertices in order determined by nature of structure and whether we do saves before or after recursive calls.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the 3 vertex orderings?

A
  • Pre-order: Put vertex on Queue before calls
  • Post-order: After calls
  • Reverse post-order: On Stack after calls
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Which vertex ordering is topological sort and why?

A

Considering edge v-w, one of the following three cases must hold when dfs(v) is called:
* dfs(w) has been called and returned (marked)
* dfs(w) not yet called, so v-w will cause dfs(w) to be called and return, before dfs(v) returns.
* dfs(w) has been called and not yet returned when dfs(v) called. This is impossible in DAG, because recursive chain implies path from w to v and v to w complete directed cycle.

In the first two cases, dfs(w) is done before dfs(v), so w after v in reverse post-order.Thus each edge points from a vertex earlier to later.

When visitng a vertex, all descendants reachable from itself have already been visited.

17
Q

What is the time complexity for topological sort?

A

V + E