Directed Graphs Flashcards
What is a directed cycle and a simple cycle?
- Directed: Path with at least one edge whose first and last vertices are the same
- Simple: Cycle with no repeated edges / vertices
What is the adjacency list representation of the DG?
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.
What is the difference between the adjacency list representation in DG compared to UDG?
UDG if v is on w’s list, then w is on v’s list. Digraph has no such symmetry.
What does the reverse()
method do?
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
What are the algorithms for Finding paths and BFS for digraphs?
algorithms are fundamental digraph algorithms. Therefore identical.
What is the single and multiple source reachagbility problem?
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 are the source reachability problems accounted for?
- Change of DFS
- 2nd constructor for DFS that takes list of vertices
What is the time for DFS in a digraph to mark all reachable vertices from a given set of sources?
Sum of out degrees that are marked.
What is topological sort?
Given a graph, put vertices in order such that all its directed from early to late
How can a DAG be identified?
The absense of a directed cycle. Can not sort topologically if cycle is present.
How do we identiy a directed cycle?
Using DFS.
Stack maintained represents current directed path under consideration.
How is the API for DIrectedCycle implemented?
- Creates integer stack Cycle which contain vertices within cycle
- ## Adds boolean array
onStack[]
where integers represent vertices, Boolean values represent their existnce oncycle
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.
What is the precedence contstrained scheduling problem?
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 do we create an algorithm for topological sort?
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.
What are the 3 vertex orderings?
- Pre-order: Put vertex on Queue before calls
- Post-order: After calls
- Reverse post-order: On Stack after calls