<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Post · Maracid's Blog</title><link>https://blog.maracid.work/posts/</link><description>All my post here include studying</description><generator>Hugo 0.167.0</generator><language>en-us</language><lastBuildDate>Sun, 11 Oct 2026 08:20:49 +0000</lastBuildDate><atom:link href="https://blog.maracid.work/posts/index.xml" rel="self" type="application/rss+xml"/><image><url>https://blog.maracid.work/favicon/apple-icon-180x180.png</url><title>Maracid's Blog</title><link>https://blog.maracid.work/</link></image><item><title>A Tiny Unix Tool Led Me To Graph Theory</title><link>https://blog.maracid.work/posts/a-tiny-unix-tool-led-me-to-graph-theory/</link><pubDate>Sat, 10 Oct 2026 00:00:00 +0000</pubDate><guid isPermaLink="true">https://blog.maracid.work/posts/a-tiny-unix-tool-led-me-to-graph-theory/</guid><dc:creator>Maracid</dc:creator><description>How I Discovered This tool As a Linux user, I'm used to using various tiny tools to solve some problems A day, When I meant to type cr, my abbreviation for clear, but I typed gc instead. Nothing …</description><content:encoded>&#10;&lt;div id="outline-container-headline-1" class="outline-2"&gt;&#10;&lt;h2 id="headline-1"&gt;&#10;How I Discovered This tool&#10;&lt;/h2&gt;&#10;&lt;div id="outline-text-headline-1" class="outline-text-2"&gt;&#10;&lt;p&gt;As a Linux user, I&amp;#39;m used to using various tiny tools to solve some problems&#10;A day, When I meant to type &lt;em&gt;cr&lt;/em&gt;, my abbreviation for clear, but I typed &lt;em&gt;gc&lt;/em&gt; instead. Nothing happened, so I decided to find out what about this tiny tool to satisfy my curious and asked an LLM how to use it.&lt;/p&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&#10;&lt;div id="outline-container-headline-2" class="outline-2"&gt;&#10;&lt;h2 id="headline-2"&gt;&#10;The Graph Theory tool&#10;&lt;/h2&gt;&#10;&lt;div id="outline-text-headline-2" class="outline-text-2"&gt;&#10;&lt;p&gt;This tool is used to count graph components, and before this, I had never encountered graph theory but I seized this opportunity to learn about it. We can do a simple test&lt;/p&gt;&#10;&lt;div class="src src-dot"&gt;&#10;&lt;pre tabindex="0"&gt;&lt;code class="language-dot" data-lang="dot"&gt;graph G {&#10; A -- B;&#10; B -- C;&#10; D -- E;&#10; F;&#10; }&lt;/code&gt;&lt;/pre&gt;&#10;&lt;/div&gt;&#10;&lt;p&gt;&#10;We will save this file as graph.dot and then &lt;code class="verbatim"&gt;gc -a graph.dot&lt;/code&gt; the output looks like this:&lt;/p&gt;&#10;&lt;div class="src src-bash"&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#ae81ff"&gt;6&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;3&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;3&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; G &lt;span style="color:#f92672"&gt;(&lt;/span&gt;graph.dot&lt;span style="color:#f92672"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&#10;&lt;/div&gt;&#10;&lt;p&gt;&#10;The simple options of gc include&lt;/p&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;-n Count nodes.&#10;-e Count edges.&#10;-c Count connected components.&#10;-a Count all. Equivalent to -encC&lt;/p&gt;&#10;&lt;/blockquote&gt;&#10;&lt;p&gt;&#10;And the output just means&lt;/p&gt;&#10;&lt;table&gt;&#10;&lt;thead&gt;&#10;&lt;tr&gt;&#10;&lt;th class="align-right"&gt;Number&lt;/th&gt;&#10;&lt;th&gt;Meaning&lt;/th&gt;&#10;&lt;/tr&gt;&#10;&lt;/thead&gt;&#10;&lt;tbody&gt;&#10;&lt;tr&gt;&#10;&lt;td class="align-right"&gt;6&lt;/td&gt;&#10;&lt;td&gt;Nodes&lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;tr&gt;&#10;&lt;td class="align-right"&gt;3&lt;/td&gt;&#10;&lt;td&gt;Edges&lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;tr&gt;&#10;&lt;td class="align-right"&gt;3&lt;/td&gt;&#10;&lt;td&gt;Connected components&lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;tr&gt;&#10;&lt;td class="align-right"&gt;1&lt;/td&gt;&#10;&lt;td&gt;Clusters&lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;/tbody&gt;&#10;&lt;/table&gt;&#10;&lt;div id="outline-container-headline-3" class="outline-3"&gt;&#10;&lt;h3 id="headline-3"&gt;&#10;Node, Edge and Connected component&#10;&lt;/h3&gt;&#10;&lt;div id="outline-text-headline-3" class="outline-text-3"&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;Connected component&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;figure&gt;&#10;&lt;img src="https://blog.maracid.work/images/Article/graph.jpeg" alt="/images/Article/graph.jpeg" title="/images/Article/graph.jpeg" /&gt;&lt;figcaption&gt;&#10;The file graph.dot just like this&#10;&lt;/figcaption&gt;&#10;&lt;/figure&gt;&#10;&lt;p&gt;&#10;We can find that&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Component 1: A can reach B and C&lt;/li&gt;&#10;&lt;li&gt;Component 2: D can reach E&lt;/li&gt;&#10;&lt;li&gt;Component 3: F has no any links, but it remains a separate connected component&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;What is nodes and edges?&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;Many things in the real world can be abstracted into a network&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Every city is a node&lt;/li&gt;&#10;&lt;li&gt;The road connecting two cities is an edge&lt;/li&gt;&#10;&lt;li&gt;Everyone is a node&lt;/li&gt;&#10;&lt;li&gt;The relationship of two people is an edge&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;&lt;strong&gt;A Node is object and edge is relationship of two objects&lt;/strong&gt;&lt;/p&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&#10;&lt;div id="outline-container-headline-4" class="outline-3"&gt;&#10;&lt;h3 id="headline-4"&gt;&#10;Clusters&#10;&lt;/h3&gt;&#10;&lt;div id="outline-text-headline-4" class="outline-text-3"&gt;&#10;&lt;p&gt;I also noticed that &lt;em&gt;gc&lt;/em&gt; reported a parameter and I didn&amp;#39;t understand what means about clusters, and I had no reason to continue exploring this parameter, so I decided to leave that question for next experiment&lt;/p&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&#10;&lt;div id="outline-container-headline-5" class="outline-2"&gt;&#10;&lt;h2 id="headline-5"&gt;&#10;Maybe GC can help me like That&#10;&lt;/h2&gt;&#10;&lt;div id="outline-text-headline-5" class="outline-text-2"&gt;&#10;&lt;p&gt;Imagine I am learning math, you can visualize the dependencies between different modules as a dependency graph&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;the &lt;code class="verbatim"&gt;derivatives&lt;/code&gt; depends on the &lt;code class="verbatim"&gt;function&lt;/code&gt; and an edge emerged&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Then the gc and help us:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;which module will depended each other?&lt;/li&gt;&#10;&lt;li&gt;Is the math module divied into several unrelated part?&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;This is only a conceptual example. I have not built this graph yet&lt;/p&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&#10;&lt;div id="outline-container-headline-6" class="outline-2"&gt;&#10;&lt;h2 id="headline-6"&gt;&#10;Future Plans&#10;&lt;/h2&gt;&#10;&lt;div id="outline-text-headline-6" class="outline-text-2"&gt;&#10;&lt;p&gt;I will not dive into graph theory so deep because I do not really understand what it could do yet&#10;&lt;em&gt;gc&lt;/em&gt; may be just a tiny tool but it may can lead a big idea&#10;This made me wonder whether graph theory could also help me organize my knowledge&#10;By the way, &lt;em&gt;gc&lt;/em&gt; is a good kickstart of into graph theory, and I need to get the most out of those tools&lt;/p&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&#10;</content:encoded></item></channel></rss>