Graph Structure Flashcards

1
Q

Bipartite Graph

A

Vertices can be divided into 2 sets A and B such that every edge has connection between A and B. And no edge connects the vertices of the same set
Use color code to differentiate. Use opposite color to the neighbours
E = O(V^2)

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

Bipartite Graph - no cycles

A

Bipartite graphs do not contain odd length cycles.
If A->B-C forms a triangle then we can’t put B-C in other set as there shouldn’t be any connection between two vertices in one set

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

Cycles

A

Starts and ends with same vertex

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

Acyclic

A

no cycles

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

Dense/Sparse tree

A

Dense: Number of edges close to Max.
Sparse: Number of edges close to Min

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

Tree

A

E = V-1 edges.
Acyclic
Sparse tree. As max of V-1 edges. Has unique path between any of part of vertices

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

Simple Graph

A

No self-loop edges
No multiple parallel edges
Num of edges : 0 to V^2

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

Adjacent Vertices

A

Undirected:If edge exists between two vertices
Directed: 0 ->1 0 is adjacent to 1, but not otherwise

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

Adjacent Edges

A

If the two edges have common node
(0,2) (2,4) 2 is common

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

Degree of Vertex

A

Undirected: Number of connections
Directed: in-degree/out-degress: num of in / out connections

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

Connected Graph

A

If there is a path between every pair of vertices. Meaning we should be able to reach any other node in a Graph.

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

connected components

A

If graph has disjoint subgraphs and each subgraph is a component. See if deleting any edge forms connected components and that edge is called cut/bridge for vertex/edge

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

Adjacency Matrix (AM)

A

2D array - 1 has connection 0 has no connection
Space: O(V^2)
Time: O(1) read/write
use for small number of edges

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

Adjacency List (AL)

A

Create V number of rows and each row contains list of of connections.
For weighted use PAIR to store vertex and weight
Space: O(V+E)
Add Edge: O(1). just append to the list
Search/Check : O(degree(v))

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

DFS

A

Time: O(V+E)
Space: O(V)

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

BFS

A

Time: O(V+E)
Space: O(V)

17
Q

Topological sorting

A

Time: O(V+E)
Space: O(V)

18
Q

SSSP

A

https://anshika-bhargava0202.medium.com/revisiting-graph-algorithms-47b08f307255#:~:text=The%20space%20complexity%20for%20adjacency,v%20need%20to%20be%20traversed.

19
Q

EL

A

Edges sorted by vertex number ascending. In undirected marked both ways
Space: O(E)
more efficient than AM & AL
Krushal’s algorithms is sample

20
Q

Drawing

A

DAG -> use fish shape
Complete -> square

21
Q

Neighbours frequently enumerated

A

AM,AL.
Check for size and drop AM if bigger

22
Q

Frequently Asked

A

AM. Check for size

23
Q

Edges needs to be sorted

A

Edge List

24
Q
A