Graphs Flashcards

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

What is a graph?

A

An abstract data type, which is a set of vertices/nodes connected to each other by edges/arcs.

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

What is an abstract data type?

A

A data structure created by the programmer rather than being implemented into the programming language.

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

What are the abstract data types i have to know about?

A

Queues
Stacks
Trees
Graphs

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

What are edges/arcs?

A

connections to nodes essentially

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

What are vertices/nodes.

A

loads of ‘locations’ essentially

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

What type can the edges be of?

A

one way or two way(bidirectional)

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

A graph with all arcs being one way is called?

A

directed or digraph

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

What is this data type often used for?

A

To represent complex relationships

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

What does it mean when an edge/arc is weighted?

A

When they have a label of a certain value to represent something e.g distance between nodes

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

How is direction represented on an edge on a graph?

A

use of arrows

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

What are the two possible types of implementation of a graph?

A

adjacency matrix

adjacency list

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

What is an adjacency list?

A

when we represent a graph by listing each node in graph and nodes connected to it

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

What is an adjacency matrix?

A

Using a e.g. 2d array to store data about a graph. Rows and columns represent nodes and their intersection is the value.

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

Why can the adjacency list implementation often very efficient compared to the matrix?

A

it is more effective to implement a sparsely connected graph, as using a matrix would leave a lot of elements with 0s in them

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

What is an advantage of an adjacency matrix?

A

simple to add an edge

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

What is a disadvantage of a adjacency matrix?

A

a sparsely connected graph will have a lot of 0 values

17
Q

What does traversing a graph mean?

A

vising every node or vertex on a graph

18
Q

What are the two methods of traversing a graph

A
  • depth first traversal

- breadth first traversal

19
Q

What is the depth- first traversal method?

A
  • uses a problem solving component of backtracking

- we go as far as we can using one route and backtrack when we hit a dead end to take another route

20
Q

What is the breadth - first traversal method?

A

When we visit all neighbours of a node that was first visited, we do this for all neighbours.

21
Q

What can graphs be used to represent?

A
  • computer networks with nodes representing computers and weighted edges representing the bandwidth between them
  • roads between towns with weighted edges representing distance/fairs or times
  • tasks in a project, where ones have to be completed before others
  • web pages and links (pagerank)
22
Q

What are graph used for?

A
  • gps

- friend suggestions on social media

23
Q

What is a cyclic graph?

A

a directed graph which contains a path from at least one node back to itself. It contains a cycle

24
Q

What is a acyclic graph?

A

a directed graph which contains absolutely no cycles, no node can be traversed back to itself