Graphs Flashcards
What is a graph?
An abstract data type, which is a set of vertices/nodes connected to each other by edges/arcs.
What is an abstract data type?
A data structure created by the programmer rather than being implemented into the programming language.
What are the abstract data types i have to know about?
Queues
Stacks
Trees
Graphs
What are edges/arcs?
connections to nodes essentially
What are vertices/nodes.
loads of ‘locations’ essentially
What type can the edges be of?
one way or two way(bidirectional)
A graph with all arcs being one way is called?
directed or digraph
What is this data type often used for?
To represent complex relationships
What does it mean when an edge/arc is weighted?
When they have a label of a certain value to represent something e.g distance between nodes
How is direction represented on an edge on a graph?
use of arrows
What are the two possible types of implementation of a graph?
adjacency matrix
adjacency list
What is an adjacency list?
when we represent a graph by listing each node in graph and nodes connected to it
What is an adjacency matrix?
Using a e.g. 2d array to store data about a graph. Rows and columns represent nodes and their intersection is the value.
Why can the adjacency list implementation often very efficient compared to the matrix?
it is more effective to implement a sparsely connected graph, as using a matrix would leave a lot of elements with 0s in them
What is an advantage of an adjacency matrix?
simple to add an edge