Author image Erich Morisse
and 1 contributors


Graph::Statistics - Perl extension for calculating network constraint and other network statistics.


  use Graph::Statistics ':all';
  # create hash representing graph
  my %g;
  foreach $f ( qw( a b c ) ) {
    foreach $t ( qw( a b c ) ) {
      next if $f eq $t;
      $g{$f}{$t} = rand();

  # every time the network changes and before calculations
  # not needed if you are only creating the graph once

  # print out Burt network constraint value for each node
  foreach $f ( keys %g ) {
    print "$f,", constraint(\%g,$f), "\n";

  # print out Coleman-Theil disorder index for each node
  foreach $f ( keys %g ) {
    print "$f,", CTdi(\%g,$f), "\n";


Calculates Burt's network constraint value on nodes within a hash based network representation. An earlier version (not public) was based on Graph, but that was too slow for networks of size.


  • constraint(hashreference, nodeidentifier)

    returns the network constraint

  • c(hash reference, node identifier a, node identifier b)

    the portion of the network constraint on a by b.

  • p(hash reference, node identifier a, node identifier b)

    the portion of the value ab of the total weights of edges from a.

  • flushCache()

    clears an internal cache used to speed everything up.

  • CTdi(hash reference, node identifier)

    Coleman-Theil disorder index. A measure of diversity of neighbor nodes.


Erich S. Morisse, <>


Copyright (C) 2009 by Erich Morisse

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 210:

You forgot a '=back' before '=head1'