Lecture 14: Graphs, networkx, and Sets
Autumn 2026
1
Sli.do
#cse163
Questions?
Icebreaker
Favorite Halloween or horror movie?
CSE 163
CSE 163: Graphs, Networkx, Sets
Announcements
2
Questions?
CSE 163: Graphs, Networkx, Sets
Inheritance
3
CSE 163: Graphs, Networkx, Sets
Inheritance Example
4
class Dog:
def __init__(self, name: str) -> None:
self._name: str = name
�
def bark(self) -> None:
print(self._name + ': Woof')
class ServiceDog(Dog):
def __init__(self, name: str, service: str) -> None:
super().__init__(name)
self._service: str = service
�
def bark(self) -> None:
print(self._name + ‘: *alert bark*')
CSE 163: Graphs, Networkx, Sets
Graphs
5
CSE 163: Graphs, Networkx, Sets
Sets
6
CSE 163: Graphs, Networkx, Sets
Set Operations
7
Mathematical Operation | In Python | Example |
Membership | in | 4 in prime → False |
Union | | | odd | prime → {1, 2, 3, 5} |
Intersection | & | odd & prime → {3, 5} |
Difference | - | odd - prime → {1} |
Symmetric difference | ^ | odd ^ prime → {1, 2} |
odd = {1, 3, 5}
prime = {2, 3, 5}
CSE 163: Graphs, Networkx, Sets
Set Methods
8
CSE 163: Graphs, Networkx, Sets
Homework 4 Tips!
9
CSE 163: Graphs, Networkx, Sets