Professional Documents
Culture Documents
Introduction To Graphs
Introduction To Graphs
• Cycles: Paths which contain one or more edges and begin/end at the same
vertex
• Sinks: Have no outgoing edges
• Sources : Have no incoming edges
• Connected if there exists a path between two vertices
• Connected component: Maximal set of vertices C such that all vertex pairs
in C are Connected
• Graphs can have multiple components and a vertex can only belong to one
component
Connectivity
• Weakly Connected
• Strongly connected directed Graphs
Real World
• Graphs arise when modelling geometric problems
• Can be used to model any type of relationship
Implementations
• Adjacency Lists
• Adjacency Matrix
Notes
• Trees are undirected connected acyclic Graphs
• Spanning Trees: Tree made out of the edge set of a Graphs
Graphs Bootcamp
• Graphs are great for modelling and analyzing relationships between pairs
of objects
1. Building a graph using an adjacency list (i.e Dict Key: vertex and Val is a
list)
2. any() in python
• Graphs used when spacially connected components
• When analyzing binary relationships (exists or Not)
• Some graph problems entail analyzing structure (finding cycles) dfs is good
for this
1
• Some graph problems are more so related to optimization (shortest path)
– BFS
– Djikstra’s algorithms
– MST algorithm