Graph Flashcards

1
Q

What is a real-world example of a Graph?

A

Imagine plotting your favourite restaurants on a map and then drawing lines between all those restaurants. That’s basically a graph. Pieces of information (The restaurants) and the Paths that run between them (The lines).

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

What is a formal definition of a Graph?

A

A Graph is a non-linear Data Structure consisting of Nodes/Vertices and Edges/Paths.

They have a finite set of Nodes(Vertices)
Nodes are connected by the Edges.

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

What is the difference between a Tree and a Graph.

A

Tree’s have a specific starting point (Root Node) and multiple branches. A Graph still has multiple branches but there is no specified starting point (Multiple starting points). We can begin from any node and traverse to any node. Like in our restaurant example you could start at any restaurant.

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

How are the vertices represented notationally?

A

E.g. { 1,2,3,4,5,6} Where each value represents a Node.

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

How are Edges represented notationally?

A

E.g. { (6,4), (4,5), (4,3), (3,2), (5,2), (2,1), (5,1) } These are the EDGE SETS. They represent the connections/paths/edges between the nodes.

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

What is it called when two nodes are connected to each other?

A

They are considered ADJACENT to each other.

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

What is an UNDIRECTED Graph?

A

A Graph in which the DIRECTION you traverse the Nodes IS NOT important. This is usually indicated by a lack of arrow.

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

What are two examples of an UNDIRECTED Graph?

A
  1. Our restaurant example. You can travel between restaurants in any direction, even back and forth if you want.
  2. Facebook Friendships. Each Edge indicates a Friendship. The friendship goes both ways and the direction is unimportant.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is an DIRECTED Graph?

A

A Graph in which the DIRECTION you traverse the Nodes IS important. This is usually indicated by arrows representing direction.

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

What is an example of an DIRECTED Graph?

A

Following someone on Instagram. E.g. I can follow Elon Musk but he doesn’t necessarily follow me back. I will have a one-way arrow edge pointing towards him.

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

Can a DIRECTED Graph’s Edges go both ways?

A

Yes. E.g. I follow someone on Instagram and they also follow me back.

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

Define a CYCLIC Graph?

A

A Graph which contains a path from at least one Node back to itself.

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

Are all UNDIRECTED Graphs CYCLICAL?

A

Yes. The bi-directional nature of Nodes within an UNDIRECTED Graph forms a cycle between any two nodes.

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

Define an ACYCLIC Graph?

A

A Graph which contains NO PATH from any one Node which leads back in on itself.

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

What is a WEIGHTED Graph?

A

A Graph whose edges are associated with a NUMERICAL VALUE. This is the COST.
Each weight represents some property of the information you’re trying to convey.

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

For our restaurant example, what would be a good WEIGHT for each EDGE if we wanted to plot a travel route amongst the restaurants?

A

The Edges’ weight could be the distance between each restaurant (Node/Vertex). This is used in route-mapping software (Google Maps) to calculate the path of LEAST-COST or WEIGHT between Nodes.

17
Q

Directed or undirected, cyclical or acyclical, weighted or unweighted can all be used to form many different variations of Graphs. What are two popular variations and their use cases?

A
  1. Undirected Cyclical Graph with Weighted Edges.
    Dijkstra’s (Dye-kstra) shortest path algorithm.
    This compiles a list of the shortest possible paths from a source vertex to all other Nodes within the Graph. Google Maps, IP Routing, Game Engines for movement.
  2. Unweighted Cyclical Graph (Undirected and Directed)
    Used in the follower/friendship system of social media websites.