CS252 Algorithms Monday, 8 April 2024 + Next up - Graphs - Exam next Monday - Info about exam Wednesday + Questions on HW, etc. + Graphs: basic definitions & facts - (Undirected) graph - Nodes/vertices (V, book uses n = |V|) - Edges (E, book uses m = |E|) - Directed graph ("digraph") - Degree of a node (undirected/directed?) - Maximum |E| - Path (undirected/directed?) - Cycle (undirected/directed?) - Eulerian path/cycle (visit every edge) - Hamiltonian path/cycle (visit every vertex) - Connected graph - Strongly connected directed graph - Weakly connected directed graph - Planar graphs - Tree - rooted tree: root, leaf - definition possibilities (there's a theorem that all 3 defs give the same objects) - *connected graph with no cycles - connected graph with n nodes and n - 1 edges - graph with n nodes, n - 1 edges, and no cycles + Implementations - Adjacency matrix - Adjacency lists + Applications - From book - transportation network (nodes = airports, edges = flights) (directed? cuz flights go one way) - communication network (nodes = computer/devices, edges = some sort of "direct" network connection) (directed? [upload/download are different]; undirected? [they can both talk]) - web pages (nodes = web pages, edges = links) (directed) - social networks (nodes = profile/account, edges = follows/friends) (directed? [twitter, instagram] undirected? [facebook, linkedin]) - dependencies (nodes = tasks, edges = task A has to be done before task B) (directed) - More ideas? - who talks to whom in harry potter, and how often? - cells in a spreadsheet (with formula references); what does a cycle mean? - regions on a map - four-color theorem - road intersections - all the mapping apps - rooms/spaces in a house - electrical connections in a microcircuit - how do you print the connections without crossings? - points in a plane (Voronoi diagrams, Delaunay triangulations) - in the proof of the art gallery theorem - late this term: network flows ==== STOPPED HERE ==== - From Slack - "Both BFS and DFS feel like very brute force algorithms, it feels like there should be a clever, faster solution..." - "In real-world comp-sci applications of graph traversal, are 'pure' BFS or 'pure' DFS ever the best option?" + Algorithm categories - Traversal - Topological sort - [Greedy Algorithms, starting with interval scheduling] - Shortest paths - Spanning trees +