Your skill will accomplishwhat the force of many cannot PerlMonks

### Comment on

 Need Help??
Hi greengaroo, The algorithm is this:- Pictorial representation:- http://picpaste.com/triplets-IQMFT1QY.jpg
```Triplets :: S=('b,c|a', 'a,c|d', 'd,e|b'),
Species :: L={a,b,c,d,e}
TreeConstruct(S):
1.] Let L be the set of species in S. Build G(L) the auxillary graph.
2.] Let C1,C2....Cq be the set of connected components in G(L).
3.] If q>1,then
- For i=1,2.....q, let S(i) be the set of triplets in S labeled by
+the set of leaves in C(i).
- Let T(i) = TreeConstruct(S(i))
- Let T be a tree formed by connecting all T(i) with the same paren
+t node. Return T.
4.]If q=1 & C1 contains exactly one leaf,return the leaf ,else return
+fail.
I have updated the code and now it takes input connections in form of triplets and prints the connected components of the graph.
```use strict;
use warnings;
use Graph;
@ARGV =  ('b,c|a', 'a,c|d', 'd,e|b') unless @ARGV;

my %HoA;
foreach ( @ARGV ) {
m/^([a-z])[,]([a-z])[|]([a-z])\$/ ;
push @{\$HoA{\$1}}, \$2;
}
print "\n===========\@HoA=====\n";
print "from->to\n";
while (my (\$key, \$values) = each %HoA) {
print \$key, "=>   [", join(',', @\$values), "]\n";
}

my \$g = Graph->new( undirected => 1 );

for my \$src ( keys %HoA ) {
for my \$tgt ( @{ \$HoA{\$src} } ) {
}
}

my @subgraphs = \$g->connected_components;
my @allgraphs;

for my \$subgraph ( @subgraphs ) {
push @allgraphs, {};
for my \$node ( @\$subgraph ) {
if ( exists \$HoA{ \$node } ) {
\$allgraphs[-1]{\$node} = [ @{ \$HoA{\$node} } ];
}
}
}
print "----connected components------------";
use YAML; print Dump \@allgraphs;
-------------OUTPUT----------------
===========@HoA=====
from->to
a=>   [c]
b=>   [c]
d=>   [e]
----connected components---------------
- a:
- c
b:
- c
- d:
- e

Hope this helps you get an idea

In reply to Re^2: phylogenetic tree construction using perl by zing
in thread phylogenetic tree construction using perl by zing

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

• Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
• Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
• Read Where should I post X? if you're not absolutely sure you're posting in the right place.
• Posts may use any of the Perl Monks Approved HTML tags:
a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
• You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
 For: Use: & & < < > > [ [ ] ]
• Link using PerlMonks shortcuts! What shortcuts can I use for linking?

Create A New User
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2017-08-24 09:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
Who is your favorite scientist and why?

Results (367 votes). Check out past polls.

Notices?