in reply to Path computation for SQL generation
So, in the context of your question you could build a hash of hashes as above, where the node names are SQL table names and there is a path from A->B if there is a foreign key relationship between tables A and B.# this hash represents a directed graph with vertices {A,B,C,D,E} and # these edges: # A -> B (weight = 3) # B -> D (weight = 1) # B -> C (weight = 1) # D -> E (weight = 1) my $hash= { 'A' => { 'B' => 3 }, 'B' => { 'D' => 1, 'C' => 1 }, 'C' => undef, 'D' => { 'E' => 1 }, 'E' => undef }; my $graph = Bio::Coordinate::Graph->new(-graph => $hash); my @node_names = shortest_path( 'A', 'E' ); # node_names now contains a list of the vertex names that make up the # shortest path (A,B,D,E)
|
|---|