@@ -35,11 +35,11 @@ of pairs of elements of $V$
3535
3636::: {.fragment .fade}
3737
38- {{< iconify game-icons team-idea >}} ** Any examples of data we could store in a graph?**
38+ {{< iconify game-icons team-idea >}} ** Any examples of data we could store in a graph? Why? **
3939
4040:::
4141
42- ## Representing a primitive graph
42+ ## A primitive graph with ` dict ` and ` list `
4343
4444``` {python}
4545graph_one = {
@@ -74,11 +74,11 @@ print(graph_two)
7474 - ` addedge(u, v) ` : Add edge to graph between vertices with keys ` u ` and ` v `
7575 - ` removeedge(u,v) ` : Remove the edge u,v from the graph
7676 - ` __contains__(v) ` : Return ` True ` if vertex ` v ` in graph; ` False ` otherwise
77- - ` hasedge(u,v) ` : Return ` True ` if edge ` (u,v) ` in graph; ` False ` otherwise.
77+ - ` hasedge(u,v) ` : Return ` True ` if edge ` (u,v) ` in graph; ` False ` otherwise
7878 - ` nbrs(v) ` : Return an iterable collection of (out)neighbors of ` v ` ,
7979 i.e., those vertices ` w ` such that ` (v, w) ` is an edge. (For directed
80- graphs, this is out-neighbors. )
81- - ` __len__() ` : Return the number of vertices in the graph.
80+ graphs, this is out-neighbors)
81+ - ` __len__() ` : Return the number of vertices in the graph
8282
8383:::
8484
@@ -120,7 +120,7 @@ class EdgeSetGraph:
120120 return len(self._V)
121121```
122122
123- ::: incremental
123+ ::: {. incremental style="margin-top: 0em; font-size: 0.95em;"}
124124
125125- Represents a graph using a set of edges between vertices
126126
@@ -144,7 +144,7 @@ print(graph.hasedge('A', 'B')) # Output: False
144144print(len(graph)) # Output: 3
145145```
146146
147- ::: incremental
147+ ::: {. incremental style="margin-top: -.4em; font-size: 0.95em;"}
148148
149149- How to create an un-directed version of the ` EdgeSetGraph ` ?
150150
@@ -410,7 +410,7 @@ def printall(G, v):
410410
411411- ` printall ` might yield ` RecursionError ` for certain graphs ` G `
412412
413- - ** Can we implement graph search without this defect?**
413+ - {{< iconify fa6-solid lightbulb >}} ** Can we implement graph search without this defect?**
414414
415415:::
416416
@@ -428,9 +428,13 @@ G = AdjacencySetGraphWithPath({1,2,3,4}, {(1,2), (2,3), (3,4), (4,1)})
428428printall(G, 1, set())
429429```
430430
431+ ::: {.fragment .fade style="margin-top: -0.25em; font-size: 0.9em;"}
432+
431433- Intuitively, this approach leaves "bread crumbs" for tracking
432434- Traversal only proceeds to vertices not visited before
433- - ** Wait, does this really print _ all_ the nodes?**
435+ - ** Wait, does this really print _ all_ the nodes? All nodes reachable?**
436+
437+ :::
434438
435439## Depth-first search (DFS)
436440
@@ -451,10 +455,10 @@ print('reachable from 1:', dfs(G, 1))
451455print('reachable from 2:', dfs(G, 2))
452456```
453457
454- ::: {.fragment style="margin-top: 0em; font-size: 0.9em ;"}
458+ ::: {.fragment style="margin-top: 0em; font-size: 0.8em ;"}
455459
456- - Graph reachability is a key concept in graph theory
457- - A depth-first search can be used to find the reachable nodes
460+ - Graph ** reachability** is a key concept in graph theory
461+ - A ** depth-first search** can be used to find the reachable nodes
458462
459463:::
460464
@@ -475,7 +479,7 @@ print("4 is connected to 1:", connected(G, 4, 1))
475479- ` connected ` uses the ` dfs ` function to determine connectivity
476480- ` connected ` returns ` True ` if there is a path between ` u ` and ` v `
477481- Otherwise, it returns ` False ` as there is no connection
478- - Useful in a wide variety of graph theoretic algorithms!
482+ - {{< iconify fa6-solid lightbulb >}} ** Useful in a wide variety of graph theoretic algorithms!**
479483
480484:::
481485
@@ -488,3 +492,23 @@ print("4 is connected to 1:", connected(G, 4, 1))
488492
489493{{< iconify fa6-solid diagram-project >}} Generalizing a ` Tree ` , a ` Graph `
490494can model real-world data!
495+
496+ # Review graph structures
497+
498+ ::: {.incremental style="margin-top: -.2em; font-size: 0.825em;"}
499+
500+ - {{< iconify fa6-solid lightbulb >}} ** Key Insight** : Graphs are objects with
501+ vertices ($V$) and edges ($E$)
502+
503+ - ** Implementations Details**
504+ - ` EdgeSetGraph ` : simple but inefficient for finding neighbors
505+ - ` AdjacencySetGraph ` : efficient neighbor access with adjacency sets
506+ - Both support ** directed** and ** undirected** versions
507+
508+ - ** Path and Cycle Operations and Graph Traversal**
509+ - Methods to verify paths, simple paths, cycles, and simple cycles
510+ - Used to analyze graph connectivity and graph structure
511+ - Depth-first search (DFS) avoids infinite loops with visited tracking
512+ - Enables connectivity testing and node reachability
513+
514+ :::
0 commit comments