Week 10 - Graph structure/ Algorithms Flashcards
What is a graph in data structures?
A graph is a data structure used to represent a collection of objects (called vertices or nodes) and the connections between them (called edges).
What is the difference between Undirected and Directed graphs?
Undirected: Edges are bidirectional (no direction).
Directed: Edges have a direction (from one vertex to another).
What is the difference between Unweighted and Weighted graphs?
Unweighted: Does not assign any numerical value to the edges.
Weighted: Assigns a numerical value (weight) to the edges.
What are the four types of graph?
- Undirected & Unweighted
- Directed & Unweighted
- Undirected & Weighted
- Directed & Weighted
What is an example of an Undirected & Unweighted graph?
Example: Facebook relationship
Vertices: Registered people
Edges: Friendships (mutual)
What is an example of a Directed & Unweighted graph?
Example: Twitter/X relationship
Vertices: Registered people
Edges: Who is following whom
What is an example of an Undirected & Weighted graph?
Example: Train map
Vertices: Train stops/stations
Edges: Rail lines connecting train stops, with their length (weight)
What is an example of a Directed & Weighted graph?
Example: Financial networks
Vertices: Bank accounts
Edges: Money transfers with the amount (weight)