SNA::Network - A toolkit for Social Network Analysis
Version 0.21
Quick summary of what the module does.
use SNA::Network; my $net = SNA::Network->new(); $net->create_node_at_index(index => 0, name => 'A'); $net->create_node_at_index(index => 1, name => 'B'); $net->create_edge(source_index => 0, target_index => 1, weight => 1); ...
SNA::Network is a bundle of modules for network algorithms, specifically designed for the needs of Social Network Analysis (SNA), but can be used for any other graph algorithms of course.
It represents a standard directed and weighted network, which can also be used as an undirected and/or unweighted network of course. It is freely extensible by using own hash entries.
Data structures have been designed for SNA-typical sparse network operations, and consist of Node and Edge objects, linked via references to each other.
Functionality is implemented in sub-modules in the SNA::Network namespace, and all methods are imported into Network.pm. So you can read the documentation in the sub-modules and call the methods from your SNA::Network instance.
Methods are called with named parameter style, e.g.
$net->method( param1 => value1, param2 => value2, ...);
Only in cases, where methods have only one parameter, this one is passed by value.
This module was implemented mainly because I had massive problems understanding the internal structures of Perl's Graph module. Despite it uses lots of arrays instead of hashes for attributes and bit setting for properties, it was terribly slow for my purposes, especially in network manipulation (consistent node removal). It currently has much more features and plugins though, and is suitable for different network types. This package is focussing on directed networks only, with the possibility to model undirected ones as well.
Creates a new empty network. There are no parameters. After creation, use methods to add nodes and edges, or load a network from a file.
Creates a node at the given index. Pass node attributes as additional named parameters, index is mandatory. Returns the created SNA::Network::Node object.
Creates a node at the next index. Pass node attributes as additional named parameters, index is forbidden. Returns the created SNA::Network::Node object with the right index field.
Creates a new edge between nodes with the given source_index and target_index. A weight is optional, it defaults to 1. Pass any additional attributes as key/value pairs. Returns the created SNA::Network::Edge object.
Returns the array of SNA::Network::Node objects belonging to this network.
Returns the SNA::Network::Node object at the given index.
Returns the array of SNA::Network::Edge objects belonging to this network.
Returns the sum of all weights of the SNA::Network::Edge objects belonging to this network.
Delete the passed node objects. These have to be sorted by index! All related edges get deleted as well. Indexes get restored after this operation.
Delete the passed edge objects.
Returns an array reference containing SNA::Network::CommunityStructure objects, which were identified by a previously executed community identification algorithm, usually the SNA::Network::Algorithm::Louvain algorithm. With a hierarchical identification algorithm, the array containts the structures of the different levels from the finest-granular structure at index 0 to the most coarsely-granular structure at the last index. If no such algorithm had been executed, it returns undef.
undef
Return a list of SNA::Network::Community objects, which were identified by a previously executed community identification algorithm, usually the SNA::Network::Algorithm::Louvain algorithm. If no such algorithm was executed, returns an empty list.
Return the modularity value based on the current communities of the network, which were identified by a previously executed community identification algorithm, usually the SNA::Network::Algorithm::Louvain algorithm. If no such algorithm was executed, returns undef.
This package can be extenden with plugins, which gives you the possibility, to add your own algorithms, filters, and so on. Each class found in the namespace SNA::Network::Plugin will be imported into the namespace of SNA::Network, and each class found in the namespace SNA::Network::Node::Plugin will be imported into the namespace of SNA::Network::Node. With this mechanism, you can add methods to these classes.
For example:
package SNA::Network::Plugin::Foo; use warnings; use strict; require Exporter; use base qw(Exporter); our @EXPORT = qw(foo); sub foo { my ($self) = @_; # $self is a reference to our network object # do something with it here ... }
adds a new foo method to SNA::Network.
SNA::Network::Node
SNA::Network::Edge
SNA::Network::Community
SNA::Network::Filter::Pajek
SNA::Network::Filter::Guess
SNA::Network::Algorithm::Betweenness
SNA::Network::Algorithm::Connectivity
SNA::Network::Algorithm::Cores
SNA::Network::Algorithm::HITS
SNA::Network::Algorithm::Louvain
SNA::Network::Algorithm::PageRank
SNA::Network::Generator::ByDensity
SNA::Network::Generator::ConfigurationModel
SNA::Network::Generator::MCMC
Darko Obradovic, <dobradovic at gmx.de>
<dobradovic at gmx.de>
Please report any bugs or feature requests to bug-sna-network at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=SNA-Network. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-sna-network at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc SNA::Network
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=SNA-Network
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/SNA-Network
CPAN Ratings
http://cpanratings.perl.org/d/SNA-Network
Search CPAN
http://search.cpan.org/dist/SNA-Network
This module has been developed as part of my work at the German Research Center for Artificial Intelligence (DFKI) http://www.dfki.de/.
Copyright 2009 Darko Obradovic, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install SNA::Network, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SNA::Network
CPAN shell
perl -MCPAN -e shell install SNA::Network
For more information on module installation, please visit the detailed CPAN module installation guide.