473,407 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Directed Graph Traversal

Can someone point me in the direction of a good solution of this? I'm
using it to construct a SQL query compiler, where each node is a table
and each edge is a join. I'm planning on using the NetworkX library if
possible.
https://networkx.lanl.gov/reference/networkx/
Given a directed graph and a list of points in the graph, what is the
minimal subgraph that contains them all? It is preferable that the
subgraph is a tree.
A -- B -- C -- D
| |
E -- F
A, B, F = ABEF (or ABCF)
A, F, C =ABCF
A, E, D =ABCD
E

Thanks!
--Buck
Apr 1 '08 #1
4 2641
On Apr 1, 3:46 pm, bukzor <workithar...@gmail.comwrote:
Can someone point me in the direction of a good solution of this? I'm
using it to construct a SQL query compiler, where each node is a table
and each edge is a join. I'm planning on using the NetworkX library if
possible.https://networkx.lanl.gov/reference/networkx/

Given a directed graph and a list of points in the graph, what is the
minimal subgraph that contains them all? It is preferable that the
subgraph is a tree.

A -- B -- C -- D
| |
E -- F

A, B, F =ABEF (or ABCF)
A, F, C =ABCF
A, E, D =ABCD
E

Thanks!
--Buck
edited to correct diagram for monospace font...
Apr 1 '08 #2
bukzor wrote:
Can someone point me in the direction of a good solution of this? I'm
using it to construct a SQL query compiler, where each node is a table
and each edge is a join. I'm planning on using the NetworkX library if
possible.
https://networkx.lanl.gov/reference/networkx/
Given a directed graph and a list of points in the graph, what is the
minimal subgraph that contains them all? It is preferable that the
subgraph is a tree.
A -- B -- C -- D
| |
E -- F
A, B, F = ABEF (or ABCF)
A, F, C =ABCF
A, E, D =ABCD
E

Thanks!
--Buck
This leaps to mind:

http://en.wikipedia.org/wiki/Kruskal's_algorithm

The implementation details are left to the reader ;)

--
----------------------------------------------------------------------------
Tim Daneliuk tu****@tundraware.com
PGP Key: http://www.tundraware.com/PGP/
Apr 1 '08 #3
bukzor wrote:
Can someone point me in the direction of a good solution of this? I'm
using it to construct a SQL query compiler, ....
Given a directed graph and a list of points in the graph, what is the
minimal subgraph that contains them all? It is preferable that the
subgraph is a tree.
I did something nice (but non-redistributable) on this once: here is the
driving intuition:

* Start with every point a distinct color.
* Add all points adjacent in the digraph as the same color; merge
colors as you join them.
* When you are down to to a single color, you have the minimal solution
in the set you've chosen.

I actually did a cheapest-first search; adding an edge each time.
There is a post-join pruning step that was (as I recall) fairly simple.

-Scott David Daniels
Sc***********@Acm.Org
Apr 3 '08 #4
On Apr 2, 8:33 pm, Scott David Daniels <Scott.Dani...@Acm.Orgwrote:
bukzor wrote:
Can someone point me in the direction of a good solution of this? I'm
using it to construct a SQL query compiler, ....
Given a directed graph and a list of points in the graph, what is the
minimal subgraph that contains them all? It is preferable that the
subgraph is a tree.

I did something nice (but non-redistributable) on this once: here is the
driving intuition:

* Start with every point a distinct color.
* Add all points adjacent in the digraph as the same color; merge
colors as you join them.
* When you are down to to a single color, you have the minimal solution
in the set you've chosen.

I actually did a cheapest-first search; adding an edge each time.
There is a post-join pruning step that was (as I recall) fairly simple.

-Scott David Daniels
Scott.Dani...@Acm.Org
That sounds like a kind of iterative deepening search, which is what
I'm planning to do. Once I have it written up, I'll post for your
pythonic enjoyment.

--Buck
Apr 3 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Lilith | last post by:
Is there a python module somewhere (been searching today, no luck) which has efficiently coded various graph-handling routines, such as finding the shortest path through a graph, or the set of all...
1
by: guy001 | last post by:
Hi, I'm trying to traverse the DOM in a bit of a non-traditional manner and am struggling to get my head around it. Just say i have some elements like so: A |-B |-C | |-D |
9
by: Mikito Harakiri | last post by:
Transitive closure (TC) of a graph is with TransClosedEdges (tail, head) as ( select tail, head from Edges union all select e.tail, ee.head from Edges e, TransClosedEdges ee where e.head =...
1
by: pocm | last post by:
Hi all, I'm at work and I don't have a copy of C Unleashed here with me, I have it at home. However, I'd like someone to confirm me that the Graph code of C Unleashed is not for Directed Graphs....
6
by: GrispernMix | last post by:
//ques and and level order traversal file name: lab6_build_leaf_up.cpp Instructions:
2
by: huiling25 | last post by:
I was given the pseudo code.. but i still cannot figure out how to do it... how can i find if the vertices are adjacent to the vertex on stack top? I know i have to have an array of true/false (to...
1
by: qiubg | last post by:
There are many nodes in the map, each of which is connected to other nodes. One way traffic for all edges, for instance, from N1 to either N2 or N3, but from N2 or N3 can’t directly go back to N1....
3
by: mistusen | last post by:
the nodes of the graph has got x and y coordinate.we'll have to draw a directed graph with the nodes in java.where can i find the source code or what is used to draw the graph?plz suggest.how can i...
6
by: Carl Banks | last post by:
I was wondering if anyone had any advice on this. This is not to study graph theory; I'm using the graph to represent a problem domain. The graphs could be arbitrarily large, and could easily...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.