I'm looking for a way to convert开发者_开发百科 signals connections to a simple scheme or graph.
Let's say I have 2 components with 2 line/signals around them:
component A:
input - S1
output - S2
component B:
input - S2
output - S1
This will be the input data file, and the output will be a scheme that shows it as 2 blocks with connecting lines around them or a illustration graph.
I'm wondering if an implementation of that exists in Perl's world.
It sounds like you want something like the graphviz graph generator.
It's written in C, but there is a Perl interface: GraphViz.
Example:
use GraphViz;
use File::Slurp qw(write_file);
my $g = GraphViz->new;
$g->add_node('componentA');
$g->add_node('componentB');
$g->add_edge('componentB' => 'componentA', label => 'S1');
$g->add_edge('componentA' => 'componentB', label => 'S2');
write_file('out.png', $g->as_png);
You could load your input data and keep track of component connections via a hash on the signal number, then call add_edge
for each one.
Output:
graphviz output http://img704.imageshack.us/img704/2624/outd.png
(labels are optional).
Cf. Graph::Easy and GraphViz.
精彩评论