<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Algorithms Q&amp;A - Recent questions and answers in Graph Theory</title>
<link>https://notexponential.com/qa/graph-theory</link>
<description>Powered by Question2Answer</description>
<item>
<title>Answered: Graph with no 3-clique that needs at least 4 colors</title>
<link>https://notexponential.com/477/graph-with-no-3-clique-that-needs-at-least-4-colors?show=956#a956</link>
<description>&lt;p&gt;Below graph does not contain any triangle and it is 4 colorable as shown. This graph is known, it is called &quot;Grötzsch Graph&quot;.&lt;/p&gt;&lt;p&gt;&lt;img alt=&quot;&quot; src=&quot;https://notexponential.com/?qa=blob&amp;amp;qa_blobid=3591421336257750378&quot; style=&quot;height:150px; width:150px&quot;&gt;&lt;/p&gt;&lt;p&gt;Some sources for more information about the graph:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://en.wikipedia.org/wiki/Gr%C3%B6tzsch_graph&quot;&gt;Wiki&lt;/a&gt;&amp;nbsp;&lt;/li&gt;&lt;li&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://mathworld.wolfram.com/GroetzschGraph.html&quot;&gt;Wolfram&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;</description>
<category>Graph Theory</category>
<guid isPermaLink="true">https://notexponential.com/477/graph-with-no-3-clique-that-needs-at-least-4-colors?show=956#a956</guid>
<pubDate>Sat, 16 Dec 2023 23:11:15 +0000</pubDate>
</item>
<item>
<title>Answered: Give an example of a graph that has 6 vertices, 9 edges, but does not have a clique on 3 vertices</title>
<link>https://notexponential.com/917/give-example-graph-that-vertices-edges-does-clique-vertices?show=929#a929</link>
<description>/Users/yingliu/Downloads/IMG_61E92A670424-1.jpeg&lt;br /&gt;
&lt;br /&gt;
Here is my answer.</description>
<category>Graph Theory</category>
<guid isPermaLink="true">https://notexponential.com/917/give-example-graph-that-vertices-edges-does-clique-vertices?show=929#a929</guid>
<pubDate>Tue, 12 Dec 2023 23:17:02 +0000</pubDate>
</item>
<item>
<title>Answered: Give an example of a graph without an articulation point, a Hamiltonian cycle, or a 2-coloring</title>
<link>https://notexponential.com/581/example-graph-without-articulation-hamiltonian-coloring?show=867#a867</link>
<description>&lt;pre&gt;&lt;span style=&quot;font-family:Times New Roman,Times,serif&quot;&gt;&lt;span style=&quot;color:#ffffff&quot;&gt;&lt;strong&gt;&lt;span style=&quot;background-color:#c0392b&quot;&gt; A&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;span style=&quot;background-color:#c0392b&quot;&gt;-&lt;/span&gt;---------&lt;span style=&quot;background-color:#2980b9&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ffffff&quot;&gt;&lt;strong&gt;&lt;span style=&quot;background-color:#2980b9&quot;&gt;B &lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;
|       |
&lt;strong&gt;&lt;span style=&quot;font-family:Times New Roman,Times,serif&quot;&gt; |             /  |  \&lt;/span&gt;
&lt;span style=&quot;font-family:Times New Roman,Times,serif&quot;&gt; |           /    |    \&lt;/span&gt;
&lt;span style=&quot;font-family:Times New Roman,Times,serif&quot;&gt; |        &lt;span style=&quot;background-color:#16a085&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color:#ffffff&quot;&gt;&lt;span style=&quot;background-color:#16a085&quot;&gt;E&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-color:#16a085&quot;&gt; &lt;/span&gt;   |     &lt;span style=&quot;color:#ffffff&quot;&gt;&lt;span style=&quot;background-color:#16a085&quot;&gt; F &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;font-family:Times New Roman,Times,serif&quot;&gt; |          \     |     /&lt;/span&gt;
&lt;span style=&quot;font-family:Times New Roman,Times,serif&quot;&gt; |            \   |   /&lt;/span&gt;&lt;/strong&gt;
|       |
&lt;span style=&quot;font-family:Times New Roman,Times,serif&quot;&gt;&lt;span style=&quot;color:#ffffff&quot;&gt;&lt;strong&gt;&lt;span style=&quot;background-color:#2980b9&quot;&gt; D&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;span style=&quot;background-color:#2980b9&quot;&gt;-&lt;/span&gt;--------&lt;span style=&quot;background-color:#c0392b&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ffffff&quot;&gt;&lt;strong&gt;&lt;span style=&quot;background-color:#c0392b&quot;&gt;C &lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;In this graph:&lt;/pre&gt;&lt;div&gt;&lt;ul&gt;&lt;li style=&quot;border: 0px solid rgb(217, 217, 227); box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-pan-x: ; --tw-pan-y: ; --tw-pinch-zoom: ; --tw-scroll-snap-strictness: proximity; --tw-gradient-from-position: ; --tw-gradient-via-position: ; --tw-gradient-to-position: ; --tw-ordinal: ; --tw-slashed-zero: ; --tw-numeric-figure: ; --tw-numeric-spacing: ; --tw-numeric-fraction: ; --tw-ring-inset: ; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; --tw-blur: ; --tw-brightness: ; --tw-contrast: ; --tw-grayscale: ; --tw-hue-rotate: ; --tw-invert: ; --tw-saturate: ; --tw-sepia: ; --tw-drop-shadow: ; --tw-backdrop-blur: ; --tw-backdrop-brightness: ; --tw-backdrop-contrast: ; --tw-backdrop-grayscale: ; --tw-backdrop-hue-rotate: ; --tw-backdrop-invert: ; --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; --tw-backdrop-sepia: ; margin: 1.25em 0px; color: rgb(55, 65, 81); font-family: Söhne, ui-sans-serif, system-ui, -apple-system, &amp;quot;Segoe UI&amp;quot;, Roboto, Ubuntu, Cantarell, &amp;quot;Noto Sans&amp;quot;, sans-serif, &amp;quot;Helvetica Neue&amp;quot;, Arial, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;; white-space-collapse: preserve;&quot;&gt;It does not have an articulation point, as removing any single vertex does not disconnect the graph.&lt;/li&gt;&lt;li style=&quot;border: 0px solid rgb(217, 217, 227); box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-pan-x: ; --tw-pan-y: ; --tw-pinch-zoom: ; --tw-scroll-snap-strictness: proximity; --tw-gradient-from-position: ; --tw-gradient-via-position: ; --tw-gradient-to-position: ; --tw-ordinal: ; --tw-slashed-zero: ; --tw-numeric-figure: ; --tw-numeric-spacing: ; --tw-numeric-fraction: ; --tw-ring-inset: ; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; --tw-blur: ; --tw-brightness: ; --tw-contrast: ; --tw-grayscale: ; --tw-hue-rotate: ; --tw-invert: ; --tw-saturate: ; --tw-sepia: ; --tw-drop-shadow: ; --tw-backdrop-blur: ; --tw-backdrop-brightness: ; --tw-backdrop-contrast: ; --tw-backdrop-grayscale: ; --tw-backdrop-hue-rotate: ; --tw-backdrop-invert: ; --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; --tw-backdrop-sepia: ; margin: 1.25em 0px; color: rgb(55, 65, 81); font-family: Söhne, ui-sans-serif, system-ui, -apple-system, &amp;quot;Segoe UI&amp;quot;, Roboto, Ubuntu, Cantarell, &amp;quot;Noto Sans&amp;quot;, sans-serif, &amp;quot;Helvetica Neue&amp;quot;, Arial, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;; white-space-collapse: preserve;&quot;&gt;It has no Hamiltonian cycle, as no cycle visits each vertex exactly once.&lt;/li&gt;&lt;li style=&quot;border: 0px solid rgb(217, 217, 227); box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-pan-x: ; --tw-pan-y: ; --tw-pinch-zoom: ; --tw-scroll-snap-strictness: proximity; --tw-gradient-from-position: ; --tw-gradient-via-position: ; --tw-gradient-to-position: ; --tw-ordinal: ; --tw-slashed-zero: ; --tw-numeric-figure: ; --tw-numeric-spacing: ; --tw-numeric-fraction: ; --tw-ring-inset: ; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; --tw-blur: ; --tw-brightness: ; --tw-contrast: ; --tw-grayscale: ; --tw-hue-rotate: ; --tw-invert: ; --tw-saturate: ; --tw-sepia: ; --tw-drop-shadow: ; --tw-backdrop-blur: ; --tw-backdrop-brightness: ; --tw-backdrop-contrast: ; --tw-backdrop-grayscale: ; --tw-backdrop-hue-rotate: ; --tw-backdrop-invert: ; --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; --tw-backdrop-sepia: ; margin: 1.25em 0px; color: rgb(55, 65, 81); font-family: Söhne, ui-sans-serif, system-ui, -apple-system, &amp;quot;Segoe UI&amp;quot;, Roboto, Ubuntu, Cantarell, &amp;quot;Noto Sans&amp;quot;, sans-serif, &amp;quot;Helvetica Neue&amp;quot;, Arial, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;; white-space-collapse: preserve;&quot;&gt;It does not have a valid 2-coloring, it requires at least 3 colors( Red, Green, Blue)&amp;nbsp;to avoid adjacent vertices having the same color- Represented in colored format in the graph.&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;</description>
<category>Graph Theory</category>
<guid isPermaLink="true">https://notexponential.com/581/example-graph-without-articulation-hamiltonian-coloring?show=867#a867</guid>
<pubDate>Wed, 06 Dec 2023 23:29:07 +0000</pubDate>
</item>
<item>
<title>Answered: Example of a graph that is connected, has articulation point, needs 4 colors, and does not have a 4-clique</title>
<link>https://notexponential.com/774/example-graph-connected-articulation-point-colors-clique?show=842#a842</link>
<description>&lt;p&gt;The following graph satisfies all the four conditions:&amp;nbsp;&lt;img alt=&quot;&quot; src=&quot;https://notexponential.com/?qa=blob&amp;amp;qa_blobid=3584187435528506884&quot; style=&quot;float:right; height:174px; width:230px&quot;&gt;&lt;/p&gt;&lt;p&gt;The connected graph has an articulation point &quot;3&quot;. Vertex coloring &quot;4&quot; as shown in image and has maximum clique of &quot;3&quot;.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;</description>
<category>Graph Theory</category>
<guid isPermaLink="true">https://notexponential.com/774/example-graph-connected-articulation-point-colors-clique?show=842#a842</guid>
<pubDate>Mon, 20 Nov 2023 01:32:44 +0000</pubDate>
</item>
<item>
<title>Answered: Polynomial time solution for Constrained Version of Tetris Problem</title>
<link>https://notexponential.com/125/polynomial-time-solution-constrained-version-tetris-problem?show=645#a645</link>
<description>The easiest way I think of is the exhaustive method. Do it with a matrix. It should be polynomial time. I cannot find a method to quickly make sure it is optimal without exhaustive method because the result seems to change time by time. I am not sure but constrained version seems do not change the time complicity? It only adds 4 possibilities.</description>
<category>Graph Theory</category>
<guid isPermaLink="true">https://notexponential.com/125/polynomial-time-solution-constrained-version-tetris-problem?show=645#a645</guid>
<pubDate>Tue, 30 Apr 2019 23:13:01 +0000</pubDate>
</item>
<item>
<title>Answered: How to generate a random connected graph?</title>
<link>https://notexponential.com/482/how-to-generate-a-random-connected-graph?show=487#a487</link>
<description>&lt;p&gt;To start, you can generate a random, connected tree by doing a random walk, except each step of the walk actually creates a the edge. This approach runs in O(V).&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Code in Python&lt;/strong&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color:#608b4e&quot;&gt;#PRE: V for the number of vertices&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color:#608b4e&quot;&gt;#POST: creates a random connected graph with a V-1 edges&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color:#569cd6&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;color:#dcdcaa&quot;&gt;generateRandomConnectedGraph&lt;/span&gt;(&lt;span style=&quot;color:#9cdcfe&quot;&gt;self&lt;/span&gt;, &lt;span style=&quot;color:#9cdcfe&quot;&gt;V&lt;/span&gt;):&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; initialSet = &lt;span style=&quot;color:#4ec9b0&quot;&gt;set&lt;/span&gt;()&lt;/p&gt;&lt;p&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/em&gt;visitedSet = &lt;span style=&quot;color:#4ec9b0&quot;&gt;set&lt;/span&gt;()&lt;/p&gt;&lt;p&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/em&gt;vertices = &lt;span style=&quot;color:#4ec9b0&quot;&gt;set&lt;/span&gt;()&lt;/p&gt;&lt;p&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/em&gt;edges = &lt;span style=&quot;color:#4ec9b0&quot;&gt;set&lt;/span&gt;()&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/em&gt;&lt;span style=&quot;color:#608b4e&quot;&gt;#generate the set of names for the vertices&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/em&gt;&lt;span style=&quot;color:#c586c0&quot;&gt;for&lt;/span&gt; i &lt;span style=&quot;color:#569cd6&quot;&gt;in&lt;/span&gt; &lt;span style=&quot;color:#dcdcaa&quot;&gt;range&lt;/span&gt;(V):&lt;/p&gt;&lt;p&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/em&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/em&gt;initialSet.add(&lt;span style=&quot;color:#4ec9b0&quot;&gt;str&lt;/span&gt;(i))&lt;/p&gt;&lt;p&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/em&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/em&gt;vertices.add(&lt;span style=&quot;color:#4ec9b0&quot;&gt;str&lt;/span&gt;(i))&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/em&gt;&lt;span style=&quot;color:#608b4e&quot;&gt;#set the intial vertex to be connected&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/em&gt;curVertex = random.sample(initialSet, &lt;span style=&quot;color:#b5cea8&quot;&gt;1&lt;/span&gt;).pop()&lt;/p&gt;&lt;p&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/em&gt;initialSet.remove(curVertex)&lt;/p&gt;&lt;p&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/em&gt;visitedSet.add(curVertex)&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/em&gt;&lt;span style=&quot;color:#608b4e&quot;&gt;#loop through all the vertices, connecting them randomly&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/em&gt;&lt;span style=&quot;color:#c586c0&quot;&gt;while&lt;/span&gt; initialSet:&lt;/p&gt;&lt;p&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/em&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/em&gt;adjVertex = random.sample(initialSet, &lt;span style=&quot;color:#b5cea8&quot;&gt;1&lt;/span&gt;).pop()&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/em&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/em&gt;edge = (random.randint(WEIGHT_MIN,WEIGHT_MAX), curVertex, adjVertex)&lt;/p&gt;&lt;p&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/em&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/em&gt;edges.add(edge)&lt;/p&gt;&lt;p&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/em&gt;initialSet.remove(adjVertex)&lt;/p&gt;&lt;p&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/em&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/em&gt;visitedSet.add(adjVertex)&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/em&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/em&gt;curVertex = adjVertex&lt;/p&gt;&lt;p&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/em&gt;return vertices, edges&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;From there, you can add random edges to the graph. I have not found a great approach to this, so the current method I use is generate all possible edges that can be created (ignoring the weights) between any two nodes and then randomly choose from that list. That generation of combinations takes O(V&lt;sup&gt;2&lt;/sup&gt;) time.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Code in Python:&lt;/strong&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;&lt;span style=&quot;color:#608b4e&quot;&gt;#PRE: the number of elements in a list&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color:#608b4e&quot;&gt;#POST: generate a 2D array of all combinations&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color:#569cd6&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;color:#dcdcaa&quot;&gt;generateCombination&lt;/span&gt;(&lt;span style=&quot;color:#9cdcfe&quot;&gt;n&lt;/span&gt;):&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; com = []&lt;/p&gt;&lt;p&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/em&gt;&lt;span style=&quot;color:#c586c0&quot;&gt;for&lt;/span&gt; i &lt;span style=&quot;color:#569cd6&quot;&gt;in&lt;/span&gt; &lt;span style=&quot;color:#dcdcaa&quot;&gt;range&lt;/span&gt;(n):&lt;/p&gt;&lt;p&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/em&gt;&lt;span style=&quot;color:#c586c0&quot;&gt;for&lt;/span&gt; j &lt;span style=&quot;color:#569cd6&quot;&gt;in&lt;/span&gt; &lt;span style=&quot;color:#dcdcaa&quot;&gt;range&lt;/span&gt;(i+&lt;span style=&quot;color:#b5cea8&quot;&gt;1&lt;/span&gt;, n):&lt;/p&gt;&lt;p&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/em&gt;com.append([i,j])&lt;/p&gt;&lt;p&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/em&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/em&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/em&gt;com.append([j,i])&lt;/p&gt;&lt;p&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/em&gt;&lt;span style=&quot;color:#c586c0&quot;&gt;return&lt;/span&gt; com&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;In total, this whole process takes O(V) + O(V&lt;sup&gt;2&lt;/sup&gt;) + O(E-A) where A is the number of edges left to generate after creating the initial tree. So a O(V&lt;sup&gt;2&lt;/sup&gt;). Not great but currently good enough for my purposes.&lt;/p&gt;</description>
<category>Graph Theory</category>
<guid isPermaLink="true">https://notexponential.com/482/how-to-generate-a-random-connected-graph?show=487#a487</guid>
<pubDate>Tue, 14 Nov 2017 16:46:03 +0000</pubDate>
</item>
<item>
<title>Answered: Heap removing and adding</title>
<link>https://notexponential.com/359/heap-removing-and-adding?show=360#a360</link>
<description>I guess that this is correct because this is the standard heapify() operation.&lt;br /&gt;
&lt;br /&gt;
The heapify() operation only assumes that both child trees are heap. Removing the top node does not break that very only assumption of the heapify() method. The pseudo-code for the method is shown below:&lt;br /&gt;
&lt;br /&gt;
procedure heapify(H)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if H.LeftChild &amp;gt; H.RightChild then&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if H.LeftChild&amp;gt;H.Root then&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;swap(H.Root,H.LeftChild);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;heapify(H.LeftChild);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;endif&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;elsif H.LeftChild &amp;lt;= H.RightChild then&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if H.RightChild&amp;gt;H.Root then&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;swap(H.Root,H.RightChild);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;heapify(H.RightChild);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;endif&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;endif&lt;br /&gt;
&lt;br /&gt;
endprocedure&lt;br /&gt;
&lt;br /&gt;
This function use recursive calls to extract the solution.</description>
<category>Graph Theory</category>
<guid isPermaLink="true">https://notexponential.com/359/heap-removing-and-adding?show=360#a360</guid>
<pubDate>Mon, 10 Oct 2016 23:52:39 +0000</pubDate>
</item>
<item>
<title>Answered: Graph Example n &gt;= 6, delta &gt;= 4, ki = 2</title>
<link>https://notexponential.com/215/graph-example-n-6-delta-4-ki-2?show=237#a237</link>
<description>Please have a look at the below explanation, I have also tried to explain the graph representation through the adjacency matrix as well.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://photos.google.com/share/AF1QipPHfLtZq6iE6BXxso_UCwU55cp5cNIcpDc0AC6YM4pkOJ9KMldP-avDcM0o_FG5Ig?key=NXBGZVI0TjM3Q19PX1NYUTNEbDRCS1ZYWXdBOHFn&quot; rel=&quot;nofollow&quot;&gt;https://photos.google.com/share/AF1QipPHfLtZq6iE6BXxso_UCwU55cp5cNIcpDc0AC6YM4pkOJ9KMldP-avDcM0o_FG5Ig?key=NXBGZVI0TjM3Q19PX1NYUTNEbDRCS1ZYWXdBOHFn&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Here, R1, R2, R3, R4 represents the RED edges and&lt;br /&gt;
B1, B2, B3, B4 represents the BLUE edges.</description>
<category>Graph Theory</category>
<guid isPermaLink="true">https://notexponential.com/215/graph-example-n-6-delta-4-ki-2?show=237#a237</guid>
<pubDate>Thu, 01 Sep 2016 05:17:34 +0000</pubDate>
</item>
<item>
<title>Answered: Graph that has 10 vertices, is 3-colorable and number of edges is maximized</title>
<link>https://notexponential.com/224/graph-that-has-vertices-colorable-and-number-edges-maximized?show=227#a227</link>
<description>&lt;p&gt;The following graph is a complete tripartite graph K&lt;sub&gt;&lt;span style=&quot;font-size:10.8333px&quot;&gt;3,3,4&lt;/span&gt;&amp;nbsp;&lt;/sub&gt;and it is a case of a complete k-partite graph. When drawing this graph, I decomposed the vertices into three disjoint sets. Every vertex of each set graph vertices is adjacent to every vertex in the other two sets. Finally, it can be clearly seen from the graph that the maximum number of edges is 33.&lt;/p&gt;&lt;p&gt;&lt;img alt=&quot;&quot; src=&quot;https://i.imgsafe.org/c96a3ac028.png&quot; style=&quot;height:479px; width:480px&quot;&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;--Updates--&lt;/p&gt;&lt;p&gt;To calculate the number of edges of K3,3,4 (Theoretically), I used the Hand-Shaking Theorem:&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;The sum of degrees of all vertices = 2 | E |.&amp;nbsp;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;The 3 vertices (dark blue) have degree 7, &amp;nbsp;3 vertices (red) &amp;nbsp;have degree 7, and last 4 vertices (light blue) have degree 6.&lt;br&gt;Therefore, the sum of the degrees of the vertices of K3,3,4 is&amp;nbsp;(3x7) + (3x7)+ (4×6) = 66.&lt;br&gt;Thus, the total number of edges is 66 ÷ 2 = 33.&lt;/p&gt;</description>
<category>Graph Theory</category>
<guid isPermaLink="true">https://notexponential.com/224/graph-that-has-vertices-colorable-and-number-edges-maximized?show=227#a227</guid>
<pubDate>Tue, 23 Aug 2016 13:35:55 +0000</pubDate>
</item>
<item>
<title>Answered: Color this graph (n=10, m=15)</title>
<link>https://notexponential.com/199/color-this-graph-n-10-m-15?show=209#a209</link>
<description>&lt;p&gt;If we start from the initial vertex, we can assign it a color (say blue)&lt;br&gt;As we keep traversing through the graph, we assign alternate colors and check for common edge between them.&lt;br&gt;&lt;br&gt;The graph has 3-chromatic number. The image is shown below.&lt;br&gt;&lt;br&gt;&lt;img alt=&quot;&quot; src=&quot;https://lh3.googleusercontent.com/-yNFDy6LZKhU/V7N1eqGoPRI/AAAAAAAALDA/usqQRy2b-Z0ucsCBt-R_zPJL_DTCcZljwCL0B/w256-h231-no/Untitled.png&quot; style=&quot;height:231px; width:256px&quot;&gt;&lt;/p&gt;</description>
<category>Graph Theory</category>
<guid isPermaLink="true">https://notexponential.com/199/color-this-graph-n-10-m-15?show=209#a209</guid>
<pubDate>Tue, 16 Aug 2016 19:43:48 +0000</pubDate>
</item>
<item>
<title>Answered: symmetry + transitivity =&gt; reflexivity, or not?</title>
<link>https://notexponential.com/128/symmetry-transitivity-reflexivity-or-not?show=140#a140</link>
<description>&lt;p&gt;&lt;span style=&quot;font-family: georgia, times new roman, times, serif; color: #222426;&quot;&gt;&lt;span style=&quot;background-color:rgb(254, 254, 254); font-size:14px; line-height:22.4px&quot;&gt;I agree with the answer above and just want to add something which may be helpful for understanding.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: georgia, times new roman, times, serif; color: #222426;&quot;&gt;&lt;span style=&quot;background-color:rgb(254, 254, 254); font-size:14px; line-height:22.4px&quot;&gt;Given a set&amp;nbsp;S = {1,2,3} and a binary relation R = {(1,2), (2,1) , (1,1), (2,2)};&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size:14px&quot;&gt;&lt;span style=&quot;background-color:rgb(254, 254, 254); color:rgb(34, 36, 38); font-family:georgia,times new roman,times,serif&quot;&gt;&quot;Reflexivity is not an internal property of a relation. Given a relation&amp;nbsp;R&lt;/span&gt;&lt;span style=&quot;background-color:rgb(254, 254, 254); color:rgb(34, 36, 38); font-family:georgia,times new roman,times,serif&quot;&gt;&amp;nbsp;we don&#039;t have a sufficient information to decide whether or not it is reflexive. The reason is that we say that&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color:rgb(254, 254, 254); color:rgb(34, 36, 38); font-family:georgia,times new roman,times,serif&quot;&gt;R&lt;/span&gt;&lt;span style=&quot;background-color:rgb(254, 254, 254); color:rgb(34, 36, 38); font-family:georgia,times new roman,times,serif&quot;&gt;&amp;nbsp;is reflexive&amp;nbsp;&lt;/span&gt;&lt;em&gt;on&amp;nbsp;S&lt;/em&gt;&lt;span style=&quot;background-color:rgb(254, 254, 254); color:rgb(34, 36, 38); font-family:georgia,times new roman,times,serif&quot;&gt;&amp;nbsp;rather than just reflexive.&quot;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size:14px&quot;&gt;&lt;span style=&quot;font-family: georgia, times new roman, times, serif; color: #222426;&quot;&gt;&lt;span style=&quot;background-color:rgb(254, 254, 254); line-height:24px&quot;&gt;To see if &amp;nbsp;relation R is reflexive on S, we need to see for every element a&amp;nbsp;in S, if &amp;nbsp;(a,a) is an element of &amp;nbsp;R, as Prof said, (3,3) is not an element of R, thus symmetry + transitivity !=&amp;gt; reflexivity&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;</description>
<category>Graph Theory</category>
<guid isPermaLink="true">https://notexponential.com/128/symmetry-transitivity-reflexivity-or-not?show=140#a140</guid>
<pubDate>Tue, 19 Jan 2016 06:58:18 +0000</pubDate>
</item>
</channel>
</rss>