Graphs Flashcards

1
Q

Degree of Vertex

A

Number of Edges sticking out of undirected graph

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

Self Loop

A

Edge starting and ending at same vertex

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

Multigraph

A

If there are two edges between 2 vertices or there are self loops.

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

Complete Graph

A

If there is an edge between every vertex of the graph

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

Graph

A

Graph is represent using G=(V,E) where V is set of all vertices, and E is set of all edges

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

Sum of degree of all vertices in undirected graph

A

Twice the number of edges 2|E|

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

Eulerian Cycle

A

Cover every edge exactly once and come back to starting position

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

Eulerian Path

A

Cover every edge exactly once but don’t come back to starting position

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

Is every EC is EP?

A

Yes, but not vice-versa

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

Connected Graph

A

If you can start from any vertex and reach any other vertex

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

Connected Component

A

Is a piece of original graph within which you can start from any vertex and reach any other vertex. But you cannot grow the connected component by adding any more vertex.

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

For Eulerian Cycle

A

Every timer we enter a vertex, we can exit it along some other edge. so the degree of vertex should be even. If the degree of any vertex is odd grapg can not have Eulerian cycle

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

If the graph is connected and degree of every vertex is even does it have Eulerian Cycle

A

Yes

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

If graph has 2 vertices with Odd Degree and rest with even degree

A

It has Eulerian Path

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

Vertices with Odd dgree 0, EC or EP?

A

Eulerian Cycle

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

Vertices with Odd degree 1, EC or EP?

A

none

17
Q

Vertices with Odd degree 2, EC or EP?

A

Eulerian Path

18
Q

Vertices with Odd degree 2,4,6 …. EC or EP?

A

Eulerian Path

19
Q

Graph Representation

A

1.Edge List: Simple but not efficient
2. Adjacency List:
3. Adjacency Matrix: n*n matrix
4. Adjacency Map:

20
Q

Number of edges at max in undirected graph

A

NC2 = n(n-1)/2 = O(n2) n => O(n square)

21
Q

Adjacency List

A

From the hashmap you get a vertex object and the class definition of vertex has an attribute which is a pointer to the adjacency list for the vertex. Vertex and adjacency list fused together called Object & Pointers approach.

This representation is not efficient if same set of vertices participate in different graph like road network, railway network or air route. Its better to save vertex separately
Facebook has millions of people and sparse graph of friendship b/w people.So better use Adjacency List.

22
Q

Adjacency Matrix

A

Symmetric Matrix: as its undirected graph. In directed graph it may not be symmetric.

Its good if we have to quickly tell if there is an edfe between u and v (u,v)

Diagonal is zero: No self loops

23
Q

Sparse Graph

A

In which |E|&laquo_space;|V|@

24
Q

Adjacency Map

A

Adjacency map uses a dictionary(hashmap key value pair) to store the neighbours of vertex v instead of list of neighbours( as in adjacency list)

25
Q

non connected graph

A

If graph is plit between multiple components, there can not be EC or EP even if the degree of every vertex is even !

26
Q
A