<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Graphs and Labels</title>
	<atom:link href="http://ivanmiljenovic.wordpress.com/2010/12/30/graphs-and-labels/feed/" rel="self" type="application/rss+xml" />
	<link>http://ivanmiljenovic.wordpress.com/2010/12/30/graphs-and-labels/</link>
	<description>Getting into blogging before it&#039;s too late</description>
	<lastBuildDate>Sun, 16 Jun 2013 06:28:36 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: DNA sequence annotation: a graph coloring problem &#171; GCBLOG</title>
		<link>http://ivanmiljenovic.wordpress.com/2010/12/30/graphs-and-labels/#comment-508</link>
		<dc:creator><![CDATA[DNA sequence annotation: a graph coloring problem &#171; GCBLOG]]></dc:creator>
		<pubDate>Mon, 18 Jun 2012 16:17:36 +0000</pubDate>
		<guid isPermaLink="false">http://ivanmiljenovic.wordpress.com/?p=164#comment-508</guid>
		<description><![CDATA[[...] are many ways to represent graphs, with several interesting implementations proposed for Haskell.  The greedy algorithm above requires that an adjacency list (a map from a [...]]]></description>
		<content:encoded><![CDATA[<p>[...] are many ways to represent graphs, with several interesting implementations proposed for Haskell.  The greedy algorithm above requires that an adjacency list (a map from a [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Thomas Bereknyei</title>
		<link>http://ivanmiljenovic.wordpress.com/2010/12/30/graphs-and-labels/#comment-369</link>
		<dc:creator><![CDATA[Thomas Bereknyei]]></dc:creator>
		<pubDate>Sun, 23 Jan 2011 03:20:51 +0000</pubDate>
		<guid isPermaLink="false">http://ivanmiljenovic.wordpress.com/?p=164#comment-369</guid>
		<description><![CDATA[Hey, I like the start of the discussion.  I have been busy with my real job for a while now, but I am still partial to this version.

class (Ord (NodeIndex g) , Ord (EdgeIndex g) ) =&gt; Graph g where
    type NodeIndex g        
    type EdgeIndex g    
    type NodeLabel g        
    type EdgeLabel g        

But this has with it the problem of duplication of labeled and unlabeled version of functions, or the ignoring of () in representing unlabeled graphs.

Another avenue might abstract out this concept of labeling something.  Along these lines?
class Labeled a where
    type Label a
    type Item a
    label :: Item a -&gt; Label a -&gt; a

instance (Control.Functor.Zip a,Labeled b) =&gt; Labeled (a b) where
    type Label (a b) = a (Label b)
    type Item (a b) = a (Item b)
    label = fzip

I just free hand wrote that, so i&#039;m sure there are issues with it, but it seems that this labeled/unlabeled split causes so many problems.  How about we try to separate that concept from the concept of a graph?  A graph being just the structure.  Then we can add labels to it.]]></description>
		<content:encoded><![CDATA[<p>Hey, I like the start of the discussion.  I have been busy with my real job for a while now, but I am still partial to this version.</p>
<p>class (Ord (NodeIndex g) , Ord (EdgeIndex g) ) =&gt; Graph g where<br />
    type NodeIndex g<br />
    type EdgeIndex g<br />
    type NodeLabel g<br />
    type EdgeLabel g        </p>
<p>But this has with it the problem of duplication of labeled and unlabeled version of functions, or the ignoring of () in representing unlabeled graphs.</p>
<p>Another avenue might abstract out this concept of labeling something.  Along these lines?<br />
class Labeled a where<br />
    type Label a<br />
    type Item a<br />
    label :: Item a -&gt; Label a -&gt; a</p>
<p>instance (Control.Functor.Zip a,Labeled b) =&gt; Labeled (a b) where<br />
    type Label (a b) = a (Label b)<br />
    type Item (a b) = a (Item b)<br />
    label = fzip</p>
<p>I just free hand wrote that, so i&#8217;m sure there are issues with it, but it seems that this labeled/unlabeled split causes so many problems.  How about we try to separate that concept from the concept of a graph?  A graph being just the structure.  Then we can add labels to it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Graph labels redux and overall plan &#171; «Insert Name Here»</title>
		<link>http://ivanmiljenovic.wordpress.com/2010/12/30/graphs-and-labels/#comment-364</link>
		<dc:creator><![CDATA[Graph labels redux and overall plan &#171; «Insert Name Here»]]></dc:creator>
		<pubDate>Mon, 17 Jan 2011 12:50:05 +0000</pubDate>
		<guid isPermaLink="false">http://ivanmiljenovic.wordpress.com/?p=164#comment-364</guid>
		<description><![CDATA[[...] Filed under: Graphs,Haskell &#8212; Ivan Miljenovic @ 10:49 PM   This is a continuation of my previous post on my thoughts and plans for writing generic graph [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Filed under: Graphs,Haskell &#8212; Ivan Miljenovic @ 10:49 PM   This is a continuation of my previous post on my thoughts and plans for writing generic graph [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ivan Miljenovic</title>
		<link>http://ivanmiljenovic.wordpress.com/2010/12/30/graphs-and-labels/#comment-362</link>
		<dc:creator><![CDATA[Ivan Miljenovic]]></dc:creator>
		<pubDate>Mon, 03 Jan 2011 09:32:08 +0000</pubDate>
		<guid isPermaLink="false">http://ivanmiljenovic.wordpress.com/?p=164#comment-362</guid>
		<description><![CDATA[Well, in general you can&#039;t make the nodes be the labels, since in a lot of cases the labels will not be unique.  However, with this new graph classes we&#039;re writing you will be able to define a graph type with any type you want for the node type.]]></description>
		<content:encoded><![CDATA[<p>Well, in general you can&#8217;t make the nodes be the labels, since in a lot of cases the labels will not be unique.  However, with this new graph classes we&#8217;re writing you will be able to define a graph type with any type you want for the node type.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason</title>
		<link>http://ivanmiljenovic.wordpress.com/2010/12/30/graphs-and-labels/#comment-360</link>
		<dc:creator><![CDATA[Jason]]></dc:creator>
		<pubDate>Mon, 03 Jan 2011 02:28:08 +0000</pubDate>
		<guid isPermaLink="false">http://ivanmiljenovic.wordpress.com/?p=164#comment-360</guid>
		<description><![CDATA[From a frequent user of FGL: Ivan, thanks for putting the effort and thought into this, I can&#039;t wait to see the first versions of the new graph libraries/classes.

From my experience with FGL I&#039;ve always needed labels on my graphs, and in my opinion, even if you were only interested in the properties of the graph itself, the internal representation of the graph nodes (Ints with FGL) still essentially represent labels. 

Additionally, my main frustration with FGL is the need to constantly handle the mapping between the Node (Int) and the labels and the associated reverse mapping. Having the label BE the node representation would simplify things greatly to my inexpert eye.]]></description>
		<content:encoded><![CDATA[<p>From a frequent user of FGL: Ivan, thanks for putting the effort and thought into this, I can&#8217;t wait to see the first versions of the new graph libraries/classes.</p>
<p>From my experience with FGL I&#8217;ve always needed labels on my graphs, and in my opinion, even if you were only interested in the properties of the graph itself, the internal representation of the graph nodes (Ints with FGL) still essentially represent labels. </p>
<p>Additionally, my main frustration with FGL is the need to constantly handle the mapping between the Node (Int) and the labels and the associated reverse mapping. Having the label BE the node representation would simplify things greatly to my inexpert eye.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sjoerd Visscher</title>
		<link>http://ivanmiljenovic.wordpress.com/2010/12/30/graphs-and-labels/#comment-358</link>
		<dc:creator><![CDATA[Sjoerd Visscher]]></dc:creator>
		<pubDate>Fri, 31 Dec 2010 16:04:22 +0000</pubDate>
		<guid isPermaLink="false">http://ivanmiljenovic.wordpress.com/?p=164#comment-358</guid>
		<description><![CDATA[Already 2011? Where do you live?]]></description>
		<content:encoded><![CDATA[<p>Already 2011? Where do you live?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sjoerd Visscher</title>
		<link>http://ivanmiljenovic.wordpress.com/2010/12/30/graphs-and-labels/#comment-357</link>
		<dc:creator><![CDATA[Sjoerd Visscher]]></dc:creator>
		<pubDate>Fri, 31 Dec 2010 14:10:04 +0000</pubDate>
		<guid isPermaLink="false">http://ivanmiljenovic.wordpress.com/?p=164#comment-357</guid>
		<description><![CDATA[When you need labels, your type just gets the LabelledNodesGraph class constraint. The class can always be implemented with const (). The class also makes sure you can change the node and graph representation without having to reimplement anything else.

If you combine nodes into one node, there could be more attributes other than the label that need combining, so it would make much more sense to require a function for combining complete Nodes.

I have to agree with vivian, a graph library should not know anything about labels. (Your arguments all similarly apply to node color for example.)]]></description>
		<content:encoded><![CDATA[<p>When you need labels, your type just gets the LabelledNodesGraph class constraint. The class can always be implemented with const (). The class also makes sure you can change the node and graph representation without having to reimplement anything else.</p>
<p>If you combine nodes into one node, there could be more attributes other than the label that need combining, so it would make much more sense to require a function for combining complete Nodes.</p>
<p>I have to agree with vivian, a graph library should not know anything about labels. (Your arguments all similarly apply to node color for example.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ivan Miljenovic</title>
		<link>http://ivanmiljenovic.wordpress.com/2010/12/30/graphs-and-labels/#comment-356</link>
		<dc:creator><![CDATA[Ivan Miljenovic]]></dc:creator>
		<pubDate>Fri, 31 Dec 2010 13:28:47 +0000</pubDate>
		<guid isPermaLink="false">http://ivanmiljenovic.wordpress.com/?p=164#comment-356</guid>
		<description><![CDATA[In just about all cases, you &lt;i&gt;do&lt;/i&gt; need an ID part, unless you can guarantee that your node labels are all unique (for edge labels this doesn&#039;t really matter, unless you want a simple graph or some such).  In general, this isn&#039;t true.

Don&#039;t get me wrong, this type of definition is very tempting.  However, I think it involves too much work/compromise to be able to &quot;scale&quot;.  Using graphviz for another example, specifically the &lt;a href=&quot;http://hackage.haskell.org/packages/archive/graphviz/2999.11.0.0/doc/html/Data-GraphViz.html#t:GraphvizParams&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;GraphvizParams&lt;/code&gt;&lt;/a&gt; type.  With the &quot;labels are compulsory&quot; specification, using it remains almost the same as it currently is.  What&#039;s more, you can then also change the underlying graph type and - as long as the label types remain the same - you can use the pre-existing GraphvizParams, etc. to visualise the graph.

However, if we go with your suggested layout, then every time you change your graph type, the transformation functions in the GraphvizParams change since there is no known structural layout that you can use: you can&#039;t even tell if there _is_ a node or edge label!  As such, functions such as these will become less generic and require more per-instance customisation because you can&#039;t tell whether or not there is a label.

Another advantage of making usage of labels explicit and compulsory: sometimes you may be wishing to compact/collapse/etc. several nodes into one.  If the presence of labels (and their types) are explicit, you can specify the requirement of a function that tells you how to combine them to form the new label.  If you don&#039;t know if there are labels or not, then creating a new node is much more difficult (another advantage of making the IDs abstract and distinct from the labels).]]></description>
		<content:encoded><![CDATA[<p>In just about all cases, you <i>do</i> need an ID part, unless you can guarantee that your node labels are all unique (for edge labels this doesn&#8217;t really matter, unless you want a simple graph or some such).  In general, this isn&#8217;t true.</p>
<p>Don&#8217;t get me wrong, this type of definition is very tempting.  However, I think it involves too much work/compromise to be able to &#8220;scale&#8221;.  Using graphviz for another example, specifically the <a href="http://hackage.haskell.org/packages/archive/graphviz/2999.11.0.0/doc/html/Data-GraphViz.html#t:GraphvizParams" rel="nofollow"><code>GraphvizParams</code></a> type.  With the &#8220;labels are compulsory&#8221; specification, using it remains almost the same as it currently is.  What&#8217;s more, you can then also change the underlying graph type and &#8211; as long as the label types remain the same &#8211; you can use the pre-existing GraphvizParams, etc. to visualise the graph.</p>
<p>However, if we go with your suggested layout, then every time you change your graph type, the transformation functions in the GraphvizParams change since there is no known structural layout that you can use: you can&#8217;t even tell if there _is_ a node or edge label!  As such, functions such as these will become less generic and require more per-instance customisation because you can&#8217;t tell whether or not there is a label.</p>
<p>Another advantage of making usage of labels explicit and compulsory: sometimes you may be wishing to compact/collapse/etc. several nodes into one.  If the presence of labels (and their types) are explicit, you can specify the requirement of a function that tells you how to combine them to form the new label.  If you don&#8217;t know if there are labels or not, then creating a new node is much more difficult (another advantage of making the IDs abstract and distinct from the labels).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sjoerd Visscher</title>
		<link>http://ivanmiljenovic.wordpress.com/2010/12/30/graphs-and-labels/#comment-355</link>
		<dc:creator><![CDATA[Sjoerd Visscher]]></dc:creator>
		<pubDate>Fri, 31 Dec 2010 13:13:19 +0000</pubDate>
		<guid isPermaLink="false">http://ivanmiljenovic.wordpress.com/?p=164#comment-355</guid>
		<description><![CDATA[What happens when you insert a node with the same ID but a different label depends on the Eq instance of your Node type. The Node type might not even include an ID and only have a label. Having ID and label separately instead of together in one Node type is what I see as more bookkeeping and more ways for things to go wrong.

You don&#039;t even need a way to differentiate between the ID part and the label part. Node identity is per Eq (or Ord) instance. And the label is extracted with the nodeLabel function in the LabelledNodesGraph class.

As there doesn&#039;t have to be a specific ID part, making it completely abstract is then no problem either, that happens almost automatically.]]></description>
		<content:encoded><![CDATA[<p>What happens when you insert a node with the same ID but a different label depends on the Eq instance of your Node type. The Node type might not even include an ID and only have a label. Having ID and label separately instead of together in one Node type is what I see as more bookkeeping and more ways for things to go wrong.</p>
<p>You don&#8217;t even need a way to differentiate between the ID part and the label part. Node identity is per Eq (or Ord) instance. And the label is extracted with the nodeLabel function in the LabelledNodesGraph class.</p>
<p>As there doesn&#8217;t have to be a specific ID part, making it completely abstract is then no problem either, that happens almost automatically.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ivan Miljenovic</title>
		<link>http://ivanmiljenovic.wordpress.com/2010/12/30/graphs-and-labels/#comment-354</link>
		<dc:creator><![CDATA[Ivan Miljenovic]]></dc:creator>
		<pubDate>Fri, 31 Dec 2010 12:48:56 +0000</pubDate>
		<guid isPermaLink="false">http://ivanmiljenovic.wordpress.com/?p=164#comment-354</guid>
		<description><![CDATA[The node IDs represent the structure.  We have to use a distinct type because in the general case the labels will have repeats.

However, if we make the overall node type part of the label, then we get duplication: say we have two nodes, &lt;code&gt;(1,&#039;a&#039;)&lt;/code&gt; and &lt;code&gt;(2,&#039;b&#039;)&lt;/code&gt;, where the first part of the tuple is the node ID and the second is the label.  Using your proposed scheme, if I want to make an edge between them then I&#039;d have to say something like: &lt;code&gt;addEdge g (1,&#039;a&#039;) (2,&#039;b&#039;) &quot;a to b&quot;&lt;/code&gt;.

So what happens here if I somehow accidentally instead did &lt;code&gt;addEdge g (1,&#039;c&#039;) (2,&#039;b&#039;) &quot;a to b&quot;&lt;/code&gt; (i.e. the label for the first node is wrong)?  Should the method accept it or fail?  And whilst it might be more of an implementation rather than an interface/representation detail, but does this mean that the node label gets stored for every edge?  Either way, this will result in more bookkeeping and more possible ways for things to go wrong.

Even if we can live with these limitations, I&#039;m not a big fan of this style because rather than just using a tuple or some such, there is no standard way of differentiating between the ID part and the label part of the node and edge types.  Instead, any time that you &lt;i&gt;do&lt;/i&gt; want to deal with that overall node type, you have to customise how you do so depending on the instance involved.

Instead, I&#039;m wanting to push towards making the ID type completely abstract.  To see what I mean, see my current draft of &lt;a href=&quot;http://code.haskell.org/~ivanm/planar-graph/&quot; rel=&quot;nofollow&quot;&gt;planar-graph&lt;/a&gt;: users of the library cannot construct node IDs directly, and instead must &quot;request&quot; new such IDs by specifying what labels they want.  If they are using a label-less graph, then defaults exist that use &lt;code&gt;mempty&lt;/code&gt; for the label value.]]></description>
		<content:encoded><![CDATA[<p>The node IDs represent the structure.  We have to use a distinct type because in the general case the labels will have repeats.</p>
<p>However, if we make the overall node type part of the label, then we get duplication: say we have two nodes, <code>(1,'a')</code> and <code>(2,'b')</code>, where the first part of the tuple is the node ID and the second is the label.  Using your proposed scheme, if I want to make an edge between them then I&#8217;d have to say something like: <code>addEdge g (1,'a') (2,'b') "a to b"</code>.</p>
<p>So what happens here if I somehow accidentally instead did <code>addEdge g (1,'c') (2,'b') "a to b"</code> (i.e. the label for the first node is wrong)?  Should the method accept it or fail?  And whilst it might be more of an implementation rather than an interface/representation detail, but does this mean that the node label gets stored for every edge?  Either way, this will result in more bookkeeping and more possible ways for things to go wrong.</p>
<p>Even if we can live with these limitations, I&#8217;m not a big fan of this style because rather than just using a tuple or some such, there is no standard way of differentiating between the ID part and the label part of the node and edge types.  Instead, any time that you <i>do</i> want to deal with that overall node type, you have to customise how you do so depending on the instance involved.</p>
<p>Instead, I&#8217;m wanting to push towards making the ID type completely abstract.  To see what I mean, see my current draft of <a href="http://code.haskell.org/~ivanm/planar-graph/" rel="nofollow">planar-graph</a>: users of the library cannot construct node IDs directly, and instead must &#8220;request&#8221; new such IDs by specifying what labels they want.  If they are using a label-less graph, then defaults exist that use <code>mempty</code> for the label value.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
