From d76abc5ea9aa0bef0adeee489f66d6b2b41a52d9 Mon Sep 17 00:00:00 2001 From: Joseph Ferano Date: Wed, 18 Jan 2023 13:54:23 +0700 Subject: [PATCH] Started chapter 5 --- TheAlgorithmDesignManual.org | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/TheAlgorithmDesignManual.org b/TheAlgorithmDesignManual.org index 0936684..44fb680 100644 --- a/TheAlgorithmDesignManual.org +++ b/TheAlgorithmDesignManual.org @@ -749,4 +749,41 @@ Fibonacci is a good example F_{n} = F_{n-1} + F_{n-2}... * Chapter 5 +** 5.1 Graphs + +Graphs are G = (E,V), so a set of edges and a set of vertices. Many real world +systems can be modeled as graphs, such as road/city networks. Many algorithmic +problems become much simpler when modeled with graphs. There are several flavors +of graphs; + +- Directed vs Undirected +- Weighted vs Unweighted +- Simple vs Non-simple +- Spares vs Dense +- Cyclic vs Acyclic +- Embedded vs Topological +- Implicted vs Explicit +- Labeled vs Unlabeled + +Social networks provide an interesting way to analyze each one of these +considerations. + +** 5.2 Data Structures for Graphs + +Which data structure we use will impact the time and space complexity of certain +operations. + +- Adjecency Matrix + You can use an /n/ x /m/ matrix, where each /(i,j)/ index answers whether an edge + exists. However, with sparse graphs, there might be a lot of wasted space. + +- Adjencency Lists + Use linked lists instead, however it is harder to verify if a certain edge + exists. This can be mitigated by collecting them in a BFS of DFS. + +#+begin_src C :includes stdio.h stdlib.h +//TODO Copy graph implementation +#+end_src + +** 5.3 War Story