Lots and lots of entire books have been written about graphs. It’s just that we wouldn’t be dealing with trees anymore — we’d be dealing with something called a graph. `S����i��͆�Ǵ�;[�q�0St�[��(o@rd-�M݉�K�wc���5��ԍ��P��L_B zZc���f�i|L������aB��8���v� C�C����"8X��!�TQ Ҳ�dÚ�A���b*uF����K���e4tM&Zѹi3�v�P\+��t�l&�`�MT��0'F�ۈ���ՠ��s1����(�9]�iS"Aʯ�F�4G.���$�˸��7� ����!�i�մj���)�#����%�*o�"�/'����ƈ����%�.��7�lGK$�@Д��7�Ő�,f��S�d���5y�\_�| ���M�-�������3;�F*�1u�'�ea����eѵ�Fj F����-IR`>�r]�P~��l =b���a6�u,��X�;)hZ�N�[�� �y��J
�?~Z�VxL�.�xw]����2��_��u4��zh}��$�r�,!|Fc�m��yV��ٸ� [��06�6�n�YY���S�#T;u�\}vB.�
gO����&���=[�W�0j�o�x"�)D��-�b�O���*���4#&����N��!e��sl]2���4����zB�!B�a��.�I+\�m�}UE3�#6�PƬ}�Y��,�sF&C�|,9���Mt�⨉X�$fs��N��p�&��-���ϐ]��.m"N�>�`%��6�v8g�-�0�,�ib�U�B�[�z�$!�X~�EN���J�v��p'�� V��*���ܴdPD�%��Hi| n%��#"�} ��ޤ/T@�� A tree with ‘n’ vertices has ‘n-1’ edges. Of course, computer science isn’t the only field to innovate and build upon what came before it, but I do think that it’s unique in one way: computer science’s innovations rely and build upon its own abstractions. In mathematics, graphs are a way to formally represent a network, which is basically just a collection of objects that are all interconnected. Non-planar graphs can require more than four colors, for example this graph:. Then, it becomes a cyclic graph which is a violation for the tree graph. Fill your mind with more graph theory awesomeness, starting with the great links below. As it turns out, when computer scientists applied graph theory to code (and ultimately implemented graphs as data structures), they didn’t change a whole lot. In a directed edge, we can only travel from the origin to the destination, and never the other way around. #FX9/H����i��^��#�#�}\N��d{�kL���x����^JG Q�
�7��d|�
-�����3(��R\9w If this is your very first foray into discrete math, fear not — it’s mine, too! There’s no concept of an “origin” and a “destination” node — instead, you’re my friend and I am yours. Just as how trees need at least one root node in order to be considered a “tree”, similarly, a graph needs at least a single node in order to be considered a “graph”. If all of the edges in a graph are undirected, the graph is said to be — you guessed it — an undirected graph! .E0Ah�G*�@��F*! is bidirectional. 5 0 obj We defined V as an unordered set of references to our 8 vertices. And trust me, some graphs really are complicated! Modeling Linear Population Growth with Matrices. For the most part (aside from one exception, which we won’t cover today), graphs can have two types of edges: a edge that has a direction or flow, and an edge that has no direction or flow. The formal, mathematical definition for a graph is just this: G = (V, E). Or, to complicate matters further, they could have some links that have direction and others that don’t! But what if we did something kind of crazy and just…threw these rules out the window? Well, it works because that ordered pair — (V, E) — is actually made up of two objects: a set of vertices, and a set of edges. Facebook, a massive social network, is a type of graph. So, which amazing abstraction shall we learn about next? But…when would we ever actually use graphs? and economics, have developed the theory behind \linear programming" and explored its applications [1]. This truth applies to everything, but boy, is it obvious in the world of computer science. In other words, a connected graph with no cycles is called a tree. Case in point: I follow Beyonce, but she definitely does not follow me back (sadly). Okay, so we know that graphs pretty much break all the rules that we know. This particularity, of course, leads us to wonder: what if this were a directed graph? When we first started looking at non-linear structures, we learned about their most fundamental characteristic: that their data doesn’t follow an order — at least, not an obvious numerical one, like we see in arrays or linked lists. [�V ;#-�p>R��Ryӣ�X�^�����/a���F3�g�Kp�pz�g�d���J:s
�����wX��_{�6�s)ۈn@�_�/��
��9�Pcm�����i�];. Sets and elements Set theory is a basis of modern mathematics, and notions of set theory are used in all formal descriptions. Each node represents … So, each of our edge objects are also unordered pairs. But, don’t be worried — we won’t be diving into the super complicated graphs today. Computer science loves to borrow stuff. Let’s stick with the simple stuff to start. Most of the graphs we’ll be dealing with are a bit more complex. It’s pretty common to refer to the node that we’re starting from as the origin, and the node that we’re traveling to as the destination. Well, you probably used one today. That’s it! The edges of a tree are known as branches. And…why should we care? Graphs also don’t have any notion of “one-directional” flow — instead, they might have direction, or they might have no direction whatsoever.