Subject: | Can get multiple edges per Graph when nodes defined more than once |
Hi,
If I add nodes that I have already added, and edges using the
add_edge_once method, it is possible to have more than one edge between
two nodes. Test case:
use Graph::Easy;
$graph = Graph::Easy->new;
my $START1 = $graph->add_node('START1');
$FORK = $graph->add_node('FORK');
$graph->add_edge_once( $START1, $FORK );
$DMT_TOU_SERVICE_POINTS_FLW =
$graph->add_node('DMT_TOU_SERVICE_POINTS_FLW');
$graph->add_edge_once( $FORK, $DMT_TOU_SERVICE_POINTS_FLW );
$AND_ACTIVITY = $graph->add_node('AND_ACTIVITY');
$graph->add_edge_once( $DMT_TOU_SERVICE_POINTS_FLW, $AND_ACTIVITY );
$DMT_ACCOUNT_GROUPS_FLW = $graph->add_node('DMT_ACCOUNT_GROUPS_FLW');
$graph->add_edge_once( $AND_ACTIVITY, $DMT_ACCOUNT_GROUPS_FLW );
$DMT_PROSPECT_AND_LOSSES_FLW =
$graph->add_node('DMT_PROSPECT_AND_LOSSES_FLW');
$graph->add_edge_once( $DMT_ACCOUNT_GROUPS_FLW,
$DMT_PROSPECT_AND_LOSSES_FLW );
$END_SUCCESS = $graph->add_node('END_SUCCESS');
$graph->add_edge_once( $DMT_PROSPECT_AND_LOSSES_FLW, $END_SUCCESS );
$DMT_TOU_CUST_ACCOUNTS_FLW = $graph->add_node('DMT_TOU_CUST_ACCOUNTS_FLW');
$graph->add_edge_once( $FORK, $DMT_TOU_CUST_ACCOUNTS_FLW );
$AND_ACTIVITY = $graph->add_node('AND_ACTIVITY');
$graph->add_edge_once( $DMT_TOU_CUST_ACCOUNTS_FLW, $AND_ACTIVITY );
$DMT_ACCOUNT_GROUPS_FLW = $graph->add_node('DMT_ACCOUNT_GROUPS_FLW');
$graph->add_edge_once( $AND_ACTIVITY, $DMT_ACCOUNT_GROUPS_FLW );
$DMT_PROSPECT_AND_LOSSES_FLW =
$graph->add_node('DMT_PROSPECT_AND_LOSSES_FLW');
$graph->add_edge_once( $DMT_ACCOUNT_GROUPS_FLW,
$DMT_PROSPECT_AND_LOSSES_FLW );
$END_SUCCESS = $graph->add_node('END_SUCCESS');
$graph->add_edge_once( $DMT_PROSPECT_AND_LOSSES_FLW, $END_SUCCESS );
$DMT_CUST_ACCOUNTS_FLW = $graph->add_node('DMT_CUST_ACCOUNTS_FLW');
$graph->add_edge_once( $FORK, $DMT_CUST_ACCOUNTS_FLW );
$AND_ACTIVITY = $graph->add_node('AND_ACTIVITY');
$graph->add_edge_once( $DMT_CUST_ACCOUNTS_FLW, $AND_ACTIVITY );
$DMT_ACCOUNT_GROUPS_FLW = $graph->add_node('DMT_ACCOUNT_GROUPS_FLW');
$graph->add_edge_once( $AND_ACTIVITY, $DMT_ACCOUNT_GROUPS_FLW );
$DMT_PROSPECT_AND_LOSSES_FLW =
$graph->add_node('DMT_PROSPECT_AND_LOSSES_FLW');
$graph->add_edge_once( $DMT_ACCOUNT_GROUPS_FLW,
$DMT_PROSPECT_AND_LOSSES_FLW );
$END_SUCCESS = $graph->add_node('END_SUCCESS');
$graph->add_edge_once( $DMT_PROSPECT_AND_LOSSES_FLW, $END_SUCCESS );
$DMT_CAMPAIGNS_FLW = $graph->add_node('DMT_CAMPAIGNS_FLW');
$graph->add_edge_once( $FORK, $DMT_CAMPAIGNS_FLW );
$AND_ACTIVITY = $graph->add_node('AND_ACTIVITY');
$graph->add_edge_once( $DMT_CAMPAIGNS_FLW, $AND_ACTIVITY );
$DMT_ACCOUNT_GROUPS_FLW = $graph->add_node('DMT_ACCOUNT_GROUPS_FLW');
$graph->add_edge_once( $AND_ACTIVITY, $DMT_ACCOUNT_GROUPS_FLW );
$DMT_PROSPECT_AND_LOSSES_FLW =
$graph->add_node('DMT_PROSPECT_AND_LOSSES_FLW');
$graph->add_edge_once( $DMT_ACCOUNT_GROUPS_FLW,
$DMT_PROSPECT_AND_LOSSES_FLW );
$END_SUCCESS = $graph->add_node('END_SUCCESS');
$graph->add_edge_once( $DMT_PROSPECT_AND_LOSSES_FLW, $END_SUCCESS );
$graph->set_attribute( 'flow', 'south' );
print $graph->as_ascii;
If I add the edge between the node names rather than the node objects, I
don't get multiple edges, i.e.:
$graph->add_edge_once( 'DMT_PROSPECT_AND_LOSSES_FLW', 'END_SUCCESS' );
vs
$graph->add_edge_once( $DMT_PROSPECT_AND_LOSSES_FLW, $END_SUCCESS );
Now it probably isn't a good idea to add a node more than once, but
according to the documentation it should have no effect. Note this
problem does not occur in 0.60 (I cannot test in any versions other then
0.60 and 0.63)
Regards
Dan