<?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/"
		>
<channel>
	<title>Comments on: Graph Theory Problem</title>
	<atom:link href="http://thesmithfam.org/blog/2008/12/12/graph-theory-problem/feed/" rel="self" type="application/rss+xml" />
	<link>http://thesmithfam.org/blog/2008/12/12/graph-theory-problem/</link>
	<description>Your blog is probably better than mine.</description>
	<lastBuildDate>Thu, 18 Mar 2010 14:19:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Carl Baker</title>
		<link>http://thesmithfam.org/blog/2008/12/12/graph-theory-problem/comment-page-1/#comment-67716</link>
		<dc:creator>Carl Baker</dc:creator>
		<pubDate>Fri, 19 Dec 2008 19:46:51 +0000</pubDate>
		<guid isPermaLink="false">http://thesmithfam.org/blog/?p=116#comment-67716</guid>
		<description>Dave,

I had some minor errors in the code I listed. Primarily, the ordered pair index values should have been 0 &amp; 1 for head and tail respectively. 

Also, you&#039;ll notice the code never does a search a separate search for nodes without parents. Since the null set is a subset of any set, the criteria for the Parent set to be a subset of the Successor set was already met.</description>
		<content:encoded><![CDATA[<p>Dave,</p>
<p>I had some minor errors in the code I listed. Primarily, the ordered pair index values should have been 0 &amp; 1 for head and tail respectively. </p>
<p>Also, you&#8217;ll notice the code never does a search a separate search for nodes without parents. Since the null set is a subset of any set, the criteria for the Parent set to be a subset of the Successor set was already met.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Carl Baker</title>
		<link>http://thesmithfam.org/blog/2008/12/12/graph-theory-problem/comment-page-1/#comment-67525</link>
		<dc:creator>Carl Baker</dc:creator>
		<pubDate>Thu, 18 Dec 2008 03:33:25 +0000</pubDate>
		<guid isPermaLink="false">http://thesmithfam.org/blog/?p=116#comment-67525</guid>
		<description>I did a quick and dirty in VBA if it helps.
&lt;pre&gt;
Enum PairType
    head = 0
    tail = 1
End Enum
    
Dim Nodes As New Scripting.Dictionary
Dim Parents As New Scripting.Dictionary
Dim Successors As New Scripting.Dictionary

Dim Pairs As Variant &#039;Variant array of ordered pairs

Sub InitPairs()
    &#039;Each pair is comprised of a head/tail duple
    Pairs = Array( _
        Array(&quot;AB&quot;, &quot;A&quot;, &quot;B&quot;), Array(&quot;AE&quot;, &quot;A&quot;, &quot;E&quot;), Array(&quot;AF&quot;, &quot;A&quot;, &quot;F&quot;), _
        Array(&quot;BA&quot;, &quot;B&quot;, &quot;A&quot;), Array(&quot;BC&quot;, &quot;B&quot;, &quot;C&quot;), _
        Array(&quot;CB&quot;, &quot;C&quot;, &quot;B&quot;), Array(&quot;CD&quot;, &quot;C&quot;, &quot;D&quot;), _
        Array(&quot;EG&quot;, &quot;E&quot;, &quot;G&quot;), Array(&quot;EH&quot;, &quot;E&quot;, &quot;H&quot;), _
        Array(&quot;HL&quot;, &quot;H&quot;, &quot;L&quot;), _
        Array(&quot;IJ&quot;, &quot;I&quot;, &quot;J&quot;), Array(&quot;IK&quot;, &quot;I&quot;, &quot;K&quot;) _
        )
End Sub

Sub Main()
    Dim pr, i As Long, node As Variant, hasParent As Boolean
    Dim parStr As String, parCh As String, succStr As String, Missing As Boolean
    &#039;Init pairs and create node list

    InitPairs
    For Each pr In Pairs
        If Not Nodes.Exists(pr(head)) Then Nodes.Add pr(head), pr(head)
        If Not Nodes.Exists(pr(tail)) Then Nodes.Add pr(tail), pr(tail)
    Next pr
    
    &#039;
    For Each node In Nodes
        Parents.Add node, &quot;&quot;
        Successors.Add node, &quot;&quot;
    Next node

    For Each pr In Pairs
        If (InStr(Parents(pr(tail)), pr(head)) = 0) Then
            Parents(pr(tail)) = Parents(pr(tail)) &amp; pr(head)
        End If
        If (InStr(Successors(pr(head)), pr(tail)) = 0) Then
            Successors(pr(head)) = Successors(pr(head)) &amp; pr(tail)
        End If
    Next pr
    
    For Each node In Nodes
        parStr = Parents(node)
        Missing = False
        succStr = Successors(node)
        For i = 1 To Len(parStr)
            parCh = Mid(parStr, i, 1)
            If InStr(succStr, parCh) = 0 Then Missing = True: Exit For
        Next i
        If Not Missing Then Debug.Print node &amp; &quot; is senior node&quot;
    Next node
    Set Nodes = Nothing
    Set Parents = Nothing
    Set Successors = Nothing
End Sub
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>I did a quick and dirty in VBA if it helps.</p>
<pre>
Enum PairType
    head = 0
    tail = 1
End Enum

Dim Nodes As New Scripting.Dictionary
Dim Parents As New Scripting.Dictionary
Dim Successors As New Scripting.Dictionary

Dim Pairs As Variant 'Variant array of ordered pairs

Sub InitPairs()
    'Each pair is comprised of a head/tail duple
    Pairs = Array( _
        Array("AB", "A", "B"), Array("AE", "A", "E"), Array("AF", "A", "F"), _
        Array("BA", "B", "A"), Array("BC", "B", "C"), _
        Array("CB", "C", "B"), Array("CD", "C", "D"), _
        Array("EG", "E", "G"), Array("EH", "E", "H"), _
        Array("HL", "H", "L"), _
        Array("IJ", "I", "J"), Array("IK", "I", "K") _
        )
End Sub

Sub Main()
    Dim pr, i As Long, node As Variant, hasParent As Boolean
    Dim parStr As String, parCh As String, succStr As String, Missing As Boolean
    'Init pairs and create node list

    InitPairs
    For Each pr In Pairs
        If Not Nodes.Exists(pr(head)) Then Nodes.Add pr(head), pr(head)
        If Not Nodes.Exists(pr(tail)) Then Nodes.Add pr(tail), pr(tail)
    Next pr

    '
    For Each node In Nodes
        Parents.Add node, ""
        Successors.Add node, ""
    Next node

    For Each pr In Pairs
        If (InStr(Parents(pr(tail)), pr(head)) = 0) Then
            Parents(pr(tail)) = Parents(pr(tail)) &amp; pr(head)
        End If
        If (InStr(Successors(pr(head)), pr(tail)) = 0) Then
            Successors(pr(head)) = Successors(pr(head)) &amp; pr(tail)
        End If
    Next pr

    For Each node In Nodes
        parStr = Parents(node)
        Missing = False
        succStr = Successors(node)
        For i = 1 To Len(parStr)
            parCh = Mid(parStr, i, 1)
            If InStr(succStr, parCh) = 0 Then Missing = True: Exit For
        Next i
        If Not Missing Then Debug.Print node &amp; " is senior node"
    Next node
    Set Nodes = Nothing
    Set Parents = Nothing
    Set Successors = Nothing
End Sub
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://thesmithfam.org/blog/2008/12/12/graph-theory-problem/comment-page-1/#comment-67524</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Thu, 18 Dec 2008 03:14:11 +0000</pubDate>
		<guid isPermaLink="false">http://thesmithfam.org/blog/?p=116#comment-67524</guid>
		<description>Carl,

That sounds promising. I think I&#039;ll code that up, and see how it works with my real data.

By the way, in case you&#039;re wondering, I&#039;m using Qt to build a QTreeView (QStandardItem-based) to represent the graph in tree form. My data is in the form of a QMap&lt;Object*,QSet&lt;Object*&gt;&gt; such that each of the map&#039;s keys maps to a set of children. The map is in no particular order.

--Dave</description>
		<content:encoded><![CDATA[<p>Carl,</p>
<p>That sounds promising. I think I&#8217;ll code that up, and see how it works with my real data.</p>
<p>By the way, in case you&#8217;re wondering, I&#8217;m using Qt to build a QTreeView (QStandardItem-based) to represent the graph in tree form. My data is in the form of a QMap&lt;Object*,QSet&lt;Object*>> such that each of the map&#8217;s keys maps to a set of children. The map is in no particular order.</p>
<p>&#8211;Dave</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Carl Baker</title>
		<link>http://thesmithfam.org/blog/2008/12/12/graph-theory-problem/comment-page-1/#comment-67504</link>
		<dc:creator>Carl Baker</dc:creator>
		<pubDate>Wed, 17 Dec 2008 23:12:27 +0000</pubDate>
		<guid isPermaLink="false">http://thesmithfam.org/blog/?p=116#comment-67504</guid>
		<description>If I understand the problem posed, it looks like you&#039;re dealing with an event-driven finite state machine. I believe that any senior node will meet one of two criteria: 
   a) the node x has no direct predecessors (or Parents), i.e. P(x) = ∅ 
   b) the node&#039;s parents are a subset of its descendants i. e., P(x) ⊆ D(x) 

I would evaluate each ordered pair&#039;s head and tail to create a Parent set and Successor set for each node. Then I&#039;d evaluate each set to see if it met the senior node criteria. 

Processing your directed graph, seems to yield the proper result as do the corner cases I tried.</description>
		<content:encoded><![CDATA[<p>If I understand the problem posed, it looks like you&#8217;re dealing with an event-driven finite state machine. I believe that any senior node will meet one of two criteria:<br />
   a) the node x has no direct predecessors (or Parents), i.e. P(x) = ∅<br />
   b) the node&#8217;s parents are a subset of its descendants i. e., P(x) ⊆ D(x) </p>
<p>I would evaluate each ordered pair&#8217;s head and tail to create a Parent set and Successor set for each node. Then I&#8217;d evaluate each set to see if it met the senior node criteria. </p>
<p>Processing your directed graph, seems to yield the proper result as do the corner cases I tried.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sasha Pachev</title>
		<link>http://thesmithfam.org/blog/2008/12/12/graph-theory-problem/comment-page-1/#comment-67318</link>
		<dc:creator>Sasha Pachev</dc:creator>
		<pubDate>Mon, 15 Dec 2008 21:26:52 +0000</pubDate>
		<guid isPermaLink="false">http://thesmithfam.org/blog/?p=116#comment-67318</guid>
		<description>Dave:

I am not sure I understand what you are saying. The Warshall algorithm will tell you for each pair of nodes (A,B) if A is a descendant of B. This allows you to go through all the nodes and compute descendant counts for each node. Once you have the counts, the most senior node is the one with the maximum number of descendants.

But actually looking at your graph with the &quot;I&quot; node, I realize that you were asking a different question. I think you need to formulate it more precisely, though. What exactly makes a node senior? Give a rule that will make node I more senior than node E.

One idea - split the graph into fully connected sub-graphs that are not connected with each other, and then declare a node to be &quot;senior&quot; if it has the most descendants in its sub-graph. In that case, the problem is split in two - build the connectivity matrix with the Warshall algorithm, then sub-divide the result. Subdivision can be done like this:

For each remaining node, pick the one with the most descendants. Exclude it along with all of its descendants. Repeat until empty.</description>
		<content:encoded><![CDATA[<p>Dave:</p>
<p>I am not sure I understand what you are saying. The Warshall algorithm will tell you for each pair of nodes (A,B) if A is a descendant of B. This allows you to go through all the nodes and compute descendant counts for each node. Once you have the counts, the most senior node is the one with the maximum number of descendants.</p>
<p>But actually looking at your graph with the &#8220;I&#8221; node, I realize that you were asking a different question. I think you need to formulate it more precisely, though. What exactly makes a node senior? Give a rule that will make node I more senior than node E.</p>
<p>One idea &#8211; split the graph into fully connected sub-graphs that are not connected with each other, and then declare a node to be &#8220;senior&#8221; if it has the most descendants in its sub-graph. In that case, the problem is split in two &#8211; build the connectivity matrix with the Warshall algorithm, then sub-divide the result. Subdivision can be done like this:</p>
<p>For each remaining node, pick the one with the most descendants. Exclude it along with all of its descendants. Repeat until empty.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://thesmithfam.org/blog/2008/12/12/graph-theory-problem/comment-page-1/#comment-67315</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Mon, 15 Dec 2008 21:09:04 +0000</pubDate>
		<guid isPermaLink="false">http://thesmithfam.org/blog/?p=116#comment-67315</guid>
		<description>David:

That looks pretty. I think it works just right (still looking it over).

--Dave</description>
		<content:encoded><![CDATA[<p>David:</p>
<p>That looks pretty. I think it works just right (still looking it over).</p>
<p>&#8211;Dave</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Owen</title>
		<link>http://thesmithfam.org/blog/2008/12/12/graph-theory-problem/comment-page-1/#comment-67311</link>
		<dc:creator>David Owen</dc:creator>
		<pubDate>Mon, 15 Dec 2008 20:16:55 +0000</pubDate>
		<guid isPermaLink="false">http://thesmithfam.org/blog/?p=116#comment-67311</guid>
		<description>The `influences` function is unchanged, but `supernodes` has been adapted.  There are plenty of optimizations around the set operations (eg, pushing only recently added nodes up to a parent, instead of all nodes), but the basic algorithm is (I think) pretty efficient.
&lt;pre&gt;
def influences(graph):
    sources = set([edge[0] for edge in graph])
    sinks = set([edge[1] for edge in graph])

    parents = dict([(s, set()) for s in sinks])
    inf = dict([(s, set()) for s in sources])
    updated = set()

    for (a, b) in graph:
        parents[b].add(a)
        inf[a].add(b)
        updated.add(a)

    while updated:
        n = updated.pop()
        hits = inf[n]
        for p in parents.get(n, []):
            phits = inf[p]
            if hits.issubset(phits): continue
            phits.update(hits)
            updated.add(p)

    return inf

def supernodes(graph):
    inf = influences(graph)
    reach = dict([(a, len(b)) for (a, b) in inf.iteritems()])
    supers = set()
    while reach:
        x = max([b for (a, b) in reach.iteritems()])
        print &#039;max&#039;, x
        new = [a for (a, b) in reach.iteritems() if b == x]
        print &#039;new&#039;, new
        supers.update(new)
        for n in new:
            if n in reach: del reach[n]
            for m in inf[n]:
                if m in reach: del reach[m]
        print reach
    return supers

graph = [(&#039;a&#039;, &#039;b&#039;),
         (&#039;a&#039;, &#039;e&#039;),
         (&#039;a&#039;, &#039;f&#039;),
         (&#039;b&#039;, &#039;a&#039;),
         (&#039;b&#039;, &#039;c&#039;),
         (&#039;c&#039;, &#039;b&#039;),
         (&#039;c&#039;, &#039;d&#039;),
         (&#039;e&#039;, &#039;g&#039;),
         (&#039;e&#039;, &#039;h&#039;),
         (&#039;h&#039;, &#039;l&#039;),
         (&#039;i&#039;, &#039;j&#039;),
         (&#039;i&#039;, &#039;k&#039;)]

print supernodes(graph)
&lt;/pre&gt;

And base64-protected :) ---

ZGVmIGluZmx1ZW5jZXMoZ3JhcGgpOgogICAgc291cmNlcyA9IHNldChbZWRnZVswXSBmb3IgZWRn
ZSBpbiBncmFwaF0pCiAgICBzaW5rcyA9IHNldChbZWRnZVsxXSBmb3IgZWRnZSBpbiBncmFwaF0p
CgogICAgcGFyZW50cyA9IGRpY3QoWyhzLCBzZXQoKSkgZm9yIHMgaW4gc2lua3NdKQogICAgaW5m
ID0gZGljdChbKHMsIHNldCgpKSBmb3IgcyBpbiBzb3VyY2VzXSkKICAgIHVwZGF0ZWQgPSBzZXQo
KQoKICAgIGZvciAoYSwgYikgaW4gZ3JhcGg6CiAgICAgICAgcGFyZW50c1tiXS5hZGQoYSkKICAg
ICAgICBpbmZbYV0uYWRkKGIpCiAgICAgICAgdXBkYXRlZC5hZGQoYSkKCiAgICB3aGlsZSB1cGRh
dGVkOgogICAgICAgIG4gPSB1cGRhdGVkLnBvcCgpCiAgICAgICAgaGl0cyA9IGluZltuXQogICAg
ICAgIGZvciBwIGluIHBhcmVudHMuZ2V0KG4sIFtdKToKICAgICAgICAgICAgcGhpdHMgPSBpbmZb
cF0KICAgICAgICAgICAgaWYgaGl0cy5pc3N1YnNldChwaGl0cyk6IGNvbnRpbnVlCiAgICAgICAg
ICAgIHBoaXRzLnVwZGF0ZShoaXRzKQogICAgICAgICAgICB1cGRhdGVkLmFkZChwKQoKICAgIHJl
dHVybiBpbmYKCmRlZiBzdXBlcm5vZGVzKGdyYXBoKToKICAgIGluZiA9IGluZmx1ZW5jZXMoZ3Jh
cGgpCiAgICByZWFjaCA9IGRpY3QoWyhhLCBsZW4oYikpIGZvciAoYSwgYikgaW4gaW5mLml0ZXJp
dGVtcygpXSkKICAgIHN1cGVycyA9IHNldCgpCiAgICB3aGlsZSByZWFjaDoKICAgICAgICB4ID0g
bWF4KFtiIGZvciAoYSwgYikgaW4gcmVhY2guaXRlcml0ZW1zKCldKQogICAgICAgIHByaW50ICdt
YXgnLCB4CiAgICAgICAgbmV3ID0gW2EgZm9yIChhLCBiKSBpbiByZWFjaC5pdGVyaXRlbXMoKSBp
ZiBiID09IHhdCiAgICAgICAgcHJpbnQgJ25ldycsIG5ldwogICAgICAgIHN1cGVycy51cGRhdGUo
bmV3KQogICAgICAgIGZvciBuIGluIG5ldzoKICAgICAgICAgICAgaWYgbiBpbiByZWFjaDogZGVs
IHJlYWNoW25dCiAgICAgICAgICAgIGZvciBtIGluIGluZltuXToKICAgICAgICAgICAgICAgIGlm
IG0gaW4gcmVhY2g6IGRlbCByZWFjaFttXQogICAgICAgIHByaW50IHJlYWNoCiAgICByZXR1cm4g
c3VwZXJzCgpncmFwaCA9IFsoJ2EnLCAnYicpLAogICAgICAgICAoJ2EnLCAnZScpLAogICAgICAg
ICAoJ2EnLCAnZicpLAogICAgICAgICAoJ2InLCAnYScpLAogICAgICAgICAoJ2InLCAnYycpLAog
ICAgICAgICAoJ2MnLCAnYicpLAogICAgICAgICAoJ2MnLCAnZCcpLAogICAgICAgICAoJ2UnLCAn
ZycpLAogICAgICAgICAoJ2UnLCAnaCcpLAogICAgICAgICAoJ2gnLCAnbCcpLAogICAgICAgICAo
J2knLCAnaicpLAogICAgICAgICAoJ2knLCAnaycpXQoKcHJpbnQgc3VwZXJub2RlcyhncmFwaCkK</description>
		<content:encoded><![CDATA[<p>The `influences` function is unchanged, but `supernodes` has been adapted.  There are plenty of optimizations around the set operations (eg, pushing only recently added nodes up to a parent, instead of all nodes), but the basic algorithm is (I think) pretty efficient.</p>
<pre>
def influences(graph):
    sources = set([edge[0] for edge in graph])
    sinks = set([edge[1] for edge in graph])

    parents = dict([(s, set()) for s in sinks])
    inf = dict([(s, set()) for s in sources])
    updated = set()

    for (a, b) in graph:
        parents[b].add(a)
        inf[a].add(b)
        updated.add(a)

    while updated:
        n = updated.pop()
        hits = inf[n]
        for p in parents.get(n, []):
            phits = inf[p]
            if hits.issubset(phits): continue
            phits.update(hits)
            updated.add(p)

    return inf

def supernodes(graph):
    inf = influences(graph)
    reach = dict([(a, len(b)) for (a, b) in inf.iteritems()])
    supers = set()
    while reach:
        x = max([b for (a, b) in reach.iteritems()])
        print 'max', x
        new = [a for (a, b) in reach.iteritems() if b == x]
        print 'new', new
        supers.update(new)
        for n in new:
            if n in reach: del reach[n]
            for m in inf[n]:
                if m in reach: del reach[m]
        print reach
    return supers

graph = [('a', 'b'),
         ('a', 'e'),
         ('a', 'f'),
         ('b', 'a'),
         ('b', 'c'),
         ('c', 'b'),
         ('c', 'd'),
         ('e', 'g'),
         ('e', 'h'),
         ('h', 'l'),
         ('i', 'j'),
         ('i', 'k')]

print supernodes(graph)
</pre>
<p>And base64-protected :) &#8212;</p>
<p>ZGVmIGluZmx1ZW5jZXMoZ3JhcGgpOgogICAgc291cmNlcyA9IHNldChbZWRnZVswXSBmb3IgZWRn<br />
ZSBpbiBncmFwaF0pCiAgICBzaW5rcyA9IHNldChbZWRnZVsxXSBmb3IgZWRnZSBpbiBncmFwaF0p<br />
CgogICAgcGFyZW50cyA9IGRpY3QoWyhzLCBzZXQoKSkgZm9yIHMgaW4gc2lua3NdKQogICAgaW5m<br />
ID0gZGljdChbKHMsIHNldCgpKSBmb3IgcyBpbiBzb3VyY2VzXSkKICAgIHVwZGF0ZWQgPSBzZXQo<br />
KQoKICAgIGZvciAoYSwgYikgaW4gZ3JhcGg6CiAgICAgICAgcGFyZW50c1tiXS5hZGQoYSkKICAg<br />
ICAgICBpbmZbYV0uYWRkKGIpCiAgICAgICAgdXBkYXRlZC5hZGQoYSkKCiAgICB3aGlsZSB1cGRh<br />
dGVkOgogICAgICAgIG4gPSB1cGRhdGVkLnBvcCgpCiAgICAgICAgaGl0cyA9IGluZltuXQogICAg<br />
ICAgIGZvciBwIGluIHBhcmVudHMuZ2V0KG4sIFtdKToKICAgICAgICAgICAgcGhpdHMgPSBpbmZb<br />
cF0KICAgICAgICAgICAgaWYgaGl0cy5pc3N1YnNldChwaGl0cyk6IGNvbnRpbnVlCiAgICAgICAg<br />
ICAgIHBoaXRzLnVwZGF0ZShoaXRzKQogICAgICAgICAgICB1cGRhdGVkLmFkZChwKQoKICAgIHJl<br />
dHVybiBpbmYKCmRlZiBzdXBlcm5vZGVzKGdyYXBoKToKICAgIGluZiA9IGluZmx1ZW5jZXMoZ3Jh<br />
cGgpCiAgICByZWFjaCA9IGRpY3QoWyhhLCBsZW4oYikpIGZvciAoYSwgYikgaW4gaW5mLml0ZXJp<br />
dGVtcygpXSkKICAgIHN1cGVycyA9IHNldCgpCiAgICB3aGlsZSByZWFjaDoKICAgICAgICB4ID0g<br />
bWF4KFtiIGZvciAoYSwgYikgaW4gcmVhY2guaXRlcml0ZW1zKCldKQogICAgICAgIHByaW50ICdt<br />
YXgnLCB4CiAgICAgICAgbmV3ID0gW2EgZm9yIChhLCBiKSBpbiByZWFjaC5pdGVyaXRlbXMoKSBp<br />
ZiBiID09IHhdCiAgICAgICAgcHJpbnQgJ25ldycsIG5ldwogICAgICAgIHN1cGVycy51cGRhdGUo<br />
bmV3KQogICAgICAgIGZvciBuIGluIG5ldzoKICAgICAgICAgICAgaWYgbiBpbiByZWFjaDogZGVs<br />
IHJlYWNoW25dCiAgICAgICAgICAgIGZvciBtIGluIGluZltuXToKICAgICAgICAgICAgICAgIGlm<br />
IG0gaW4gcmVhY2g6IGRlbCByZWFjaFttXQogICAgICAgIHByaW50IHJlYWNoCiAgICByZXR1cm4g<br />
c3VwZXJzCgpncmFwaCA9IFsoJ2EnLCAnYicpLAogICAgICAgICAoJ2EnLCAnZScpLAogICAgICAg<br />
ICAoJ2EnLCAnZicpLAogICAgICAgICAoJ2InLCAnYScpLAogICAgICAgICAoJ2InLCAnYycpLAog<br />
ICAgICAgICAoJ2MnLCAnYicpLAogICAgICAgICAoJ2MnLCAnZCcpLAogICAgICAgICAoJ2UnLCAn<br />
ZycpLAogICAgICAgICAoJ2UnLCAnaCcpLAogICAgICAgICAoJ2gnLCAnbCcpLAogICAgICAgICAo<br />
J2knLCAnaicpLAogICAgICAgICAoJ2knLCAnaycpXQoKcHJpbnQgc3VwZXJub2RlcyhncmFwaCkK</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://thesmithfam.org/blog/2008/12/12/graph-theory-problem/comment-page-1/#comment-67306</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Mon, 15 Dec 2008 18:45:43 +0000</pubDate>
		<guid isPermaLink="false">http://thesmithfam.org/blog/?p=116#comment-67306</guid>
		<description>Sasha:

The Warshall algorithm will certainly find all the nodes and their descendants&#039; tree height. I don&#039;t argue that. What I find wrong with your approach is measuring the depth of each nodes&#039; descendants tree and choosing the parent nodes with the maximum height. In the third figure above, that would omit node &quot;I&quot;, not because &quot;I&quot; is part of a disconnected graph, but because its tree height is smaller than that of &quot;A&quot;, &quot;B&quot;, and &quot;C&quot;.</description>
		<content:encoded><![CDATA[<p>Sasha:</p>
<p>The Warshall algorithm will certainly find all the nodes and their descendants&#8217; tree height. I don&#8217;t argue that. What I find wrong with your approach is measuring the depth of each nodes&#8217; descendants tree and choosing the parent nodes with the maximum height. In the third figure above, that would omit node &#8220;I&#8221;, not because &#8220;I&#8221; is part of a disconnected graph, but because its tree height is smaller than that of &#8220;A&#8221;, &#8220;B&#8221;, and &#8220;C&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sasha Pachev</title>
		<link>http://thesmithfam.org/blog/2008/12/12/graph-theory-problem/comment-page-1/#comment-67303</link>
		<dc:creator>Sasha Pachev</dc:creator>
		<pubDate>Mon, 15 Dec 2008 17:59:24 +0000</pubDate>
		<guid isPermaLink="false">http://thesmithfam.org/blog/?p=116#comment-67303</guid>
		<description>Dave:

Warshall algorithm will find all nodes. It does not really care if the graph is fully connected since it works with a connectivity matrix rather than starting from a node and traversing the graph. Basically the idea is that for each  node we pour colored water into it and then see which other nodes eventually have water of that color.</description>
		<content:encoded><![CDATA[<p>Dave:</p>
<p>Warshall algorithm will find all nodes. It does not really care if the graph is fully connected since it works with a connectivity matrix rather than starting from a node and traversing the graph. Basically the idea is that for each  node we pour colored water into it and then see which other nodes eventually have water of that color.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://thesmithfam.org/blog/2008/12/12/graph-theory-problem/comment-page-1/#comment-67205</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Sun, 14 Dec 2008 17:14:07 +0000</pubDate>
		<guid isPermaLink="false">http://thesmithfam.org/blog/?p=116#comment-67205</guid>
		<description>Aaron: Stating the problem as &quot;the nodes with the most descendants&quot; is misleading, as you suggest.  I&#039;m struggling to verbalize the problem myself, since obviously my graph theory is weak, so I hope the pictures (especially the third one) speak for themselves.

Let me explain the problem&#039;s context. I am developing a GUI that uses a common tree view, like what you might see in a file browser. I am given a graph like the ones pictured above, and need to translate that into the tree view display full of expandable and collapsible nodes (with possibly multiple root nodes).

Does that help at all?</description>
		<content:encoded><![CDATA[<p>Aaron: Stating the problem as &#8220;the nodes with the most descendants&#8221; is misleading, as you suggest.  I&#8217;m struggling to verbalize the problem myself, since obviously my graph theory is weak, so I hope the pictures (especially the third one) speak for themselves.</p>
<p>Let me explain the problem&#8217;s context. I am developing a GUI that uses a common tree view, like what you might see in a file browser. I am given a graph like the ones pictured above, and need to translate that into the tree view display full of expandable and collapsible nodes (with possibly multiple root nodes).</p>
<p>Does that help at all?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
