pages tagged idea http://meng6net.localhost/tag/idea/ <p><small>Copyright © 2005-2020 by <code>Meng Lu &lt;lumeng3@gmail.com&gt;</code></small></p> Meng Lu's home page ikiwiki Tue, 16 May 2017 23:59:39 +0000 Graphlet: a readable serialized representation of graphs http://meng6net.localhost/blog/graphlet/ http://meng6net.localhost/blog/graphlet/ graph idea library science metadata notation Tue, 16 May 2017 23:59:39 +0000 2017-05-16T23:59:39Z <p>A tree graph is uniquely identified by the set of its edges</p> <pre> <code>{1-&gt;2, 1-&gt;3, 2-&gt;4, 2-&gt;5, 2-&gt;6, 3-&gt;7, 3-&gt;8} </code></pre> <p>This syntax is used in <a href= "http://reference.wolfram.com/language/ref/Graph.html">Wolfram Language's graph specification</a>. The actual picture of the graph can be displayed in Mathematica with:</p> <pre> <code>Graph[{1 -&gt; 2, 1 -&gt; 3, 2 -&gt; 4, 2 -&gt; 5, 2 -&gt; 6, 3 -&gt; 7, 3 -&gt; 8}] </code></pre> <p>It can be <a href= "https://www.wolframalpha.com/input/?t=crmtb01&amp;f=ob&amp;i=graph%201%20-%3E%202%2C%201%20-%3E%203%2C%202%20-%3E%204%2C%202%20-%3E%205%2C%202%20-%3E%206%2C%203%20-%3E%207%2C%203%20-%3E%208"> drawn in Wolfram|Alpha conveniently with query "graph 1 -&gt; 2, 1 -&gt; 3, 2 -&gt; 4, 2 -&gt; 5, 2 -&gt; 6, 3 -&gt; 7, 3 -&gt; 8"</a>.</p> <p>The question is: is there a better way to represent the graph in a compact, readable, and text-only form?</p> <h2>Why?</h2> <p>A few use cases which might give some motivation:</p> <ol> <li> <p>In tweets, sometimes, one might want to include graphs accurately represented by a short sequence of regular characters, which ideally should also be easy to parse as-is (instead of only after being processed by software such as Mathematica's <code>Graph[...]</code> function.)</p> </li> <li> <p>When labeling/classifying objects, besides using tags which are a flat list of IDs of form <code>{tag1, tag2, ...}</code> and equivalent to a graph with vertexes but no edges, one can use a tree graph represented in a succinct form to carry more information about the hierarchical classification of the object.</p> </li> </ol> <h2>One way: list of tags</h2> <p>One obvious way is to write the list of edges such as <code>{1-&gt;2, 1-&gt;3,2-&gt;4, 2-&gt;5, 2-&gt;6, 3-&gt;7, 3-&gt;8}</code>, which uniquely identifies the graph. It's not very compact -- vertexes with multiple children is repeated -- and neither very readable -- one need to do much mental processing and memorizing in order to understand and imagine the structure of the graph.</p> <h2>Another way: "graphlet"</h2> <p>Another way I designed is to write it into the following form, which I dubbed "graphlet representation" of (tree) graphs:</p> <pre><code>1`{2`{4, 5, 6}, 3`{7, 8}} </code></pre> <p>So, in graphlet representation:</p> <ol> <li> <p>The edges in a graph are represented by an edge character (backtick for instance);</p> </li> <li> <p>Child vertexes are grouped by a pair of grouping characters (<code>{</code> and <code>}</code> for instance).</p> </li> </ol> <p>Note that the graphlet representation is shorter than the flat list-of-edges representation.</p> <h2>Classification graphlet is more informative than list of tags</h2> <p>An object's classification is often represented as a list of tags</p> <pre><code>{tag1, tag2, ..., tag8} </code></pre> <p>However, if the classification is hierarchical, a graphlet representation can easily records more information about the classification structure:</p> <pre><code>tag1`{tag2`{tag4, tag5, tag6}, tag3`{tag7, tag8}} </code></pre> <h3>Application examples</h3> <p>To represent the classification of a problem, a sequence of key words is often used, e.g.</p> <pre> <code>astrophysics, cosmology, general-relativity, star, galaxy </code></pre> <p>One can actually additionally include its hierarchical classification structure by using a graphlet:</p> <pre> <code>science`{physics`{astrophysics, cosmology, general-relativity}, astronomy`{star, galaxy}} </code></pre> <h3>Advantages</h3> <p>Preserving the full graph structure, many graph characteristics can be exploited, and graph-theoretic methods can be used for analyzing metadata in this form. For example, graphlets can be systematically shorten/simplified by pruning leaves.</p> /blog/graphlet/#comments