Graphs Flashcards
What is a graph?
A data structure designed to represent the relationship between items
What is a node/vertex of a graph?
A representation of an item of data, often drawn as a circle.
What is an edge/arc of graph?
A line used to represent the relationship between two nodes
Describe a weighted graph
Each edge has a value/cost attributed to it
Describe a directed graph
A graph in which some edges can only be traversed in one direction
Describe a disconnected graph
A graph which two or more nodes are not connected to the graph
What are the uses of a graph data structure?
Route finding
Representing networks in human relationships
Computer networks
Project management
Game theory (mathematical modelling of strategic decisions)
What is an adjacency list?
A method of representing a graph by listing, for each node just the nodes that are directly connected to it directly
What is an adjacency matrix?
A method of representing a grid with values in each cell to show which nodes are connected to each other?
What are the advantages and disadvantages of an adjacency list?
+ Good for sparse graphs (few edges) or situations where edges don’t need to be tested often as it takes up less space
- Poor for dense graphs as it takes too long to process each value
What are the advantages and disadvantages of an adjacency matrix?
+ Good for dense graphs (many edges) or situations where edges need to be tested often as it’s easier to process each value
- Poor for sparse graphs as it wastes storage space