<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Algorithms and Stuff &#187; transitive</title>
	<atom:link href="http://blog.ivank.net/tag/transitive/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.ivank.net</link>
	<description>Algorithms and Stuff</description>
	<lastBuildDate>Thu, 14 Mar 2013 18:36:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Binary relations and closures</title>
		<link>http://blog.ivank.net/relations-closure.html</link>
		<comments>http://blog.ivank.net/relations-closure.html#comments</comments>
		<pubDate>Fri, 21 Oct 2011 18:44:11 +0000</pubDate>
		<dc:creator>Ivan Kuckir</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Math]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[binary relation]]></category>
		<category><![CDATA[closure]]></category>
		<category><![CDATA[compute]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[transitive]]></category>
		<category><![CDATA[visualization]]></category>

		<guid isPermaLink="false">http://blog.ivank.net/?p=385</guid>
		<description><![CDATA[I have made a little tool. Here you can specify some binary relation over a finite set. Then you can generate a closure of it. How to use it Click on checkbox with coordinates (x, y) to make it the element of relation. The closure is marked with black squares behind checkboxes. You can specify [...]]]></description>
			<content:encoded><![CDATA[<p>I have made a little tool. Here you can specify some binary relation over a finite set. Then you can generate a closure of it.</p>
<p><span id="more-385"></span></p>
<p><iframe height="620"  src="http://www.ivank.net/blogspot/relations.html" style="border: 5px solid #282923;" width="650"></iframe>  </p>
<h2>How to use it</h2>
<p>Click on checkbox with coordinates (x, y) to make it the element of relation. The closure is marked with black squares behind checkboxes. You can specify some criteria for closure (reflexivity, symmetry, transitivity).</p>
<h2>Code</h2>
<p>I decided to use recursive attitude to make a closure. At the beginning, add or not add a diagonal, according to reflexivity checkbox. Then I call CloseCell(x, y) on each &#8220;cell&#8221; (pair) defined by user. It marks it as &#8220;done&#8221; (bool matrix &#8220;rdone&#8221;), it sets a relation value (bool matrix &#8220;r&#8221;) and recursively cals CloseCell on other cells, when transitivity or symmetry was checked.</p>
<pre name="dlhl" class="js">
function CloseCell(i, j)
{
   if(rdone[i][j]) return;
   r[i][j] = rdone[i][j] = true;

   // if symmetric
   if(c.sym) CloseCell(j, i);

   // if transitive
   if(c.tra) for(var k=0; k&lt;n; k++) if(r[j][k]) CloseCell(i, k);
}
</pre>
<h2>Correctness</h2>
<p>As you see, I didn&#8217;t use a classic Floyd-Warshall-like attitude to make transitive closure. It seems that it works, but I am not sure with it&#8217;s correctness (I don&#8217;t know why it works). If you find some proof of correctness, or you find a relation, when closure is incorrect, please let me know <img src='http://blog.ivank.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  .</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ivank.net/relations-closure.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
