The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Graph::SocialMap - Easy tool to create social network map

SYNOPSIS

    # The Structure of relationship
    my $relation = {
        1357 => [qw/Marry Rose/],
        3579 => [qw/Marry Peacock/],
        2468 => [qw/Joan/],
        4680 => [qw/Rose Joan/],
        OSSF => [qw/Gugod Autrijus/],
    };

    # Generate a Graph::SocialMap object.
    my $gsm = Graph::SocialMap->new(relation => $relation) ;

    # Type 1 SocialMap
    my $graph_type1 = $gsm->type1;

    # Type 2 SocialMap
    my $graph_type2 = $gsm->type2;

    # Save it with Graph::Writer::* module
    my $writer = Graph::Writer::DGF->new();
    $writer->write_graph($graph_type1,'type1.dgf');

    # Weight of person (equal to the number of occurence)
    # Should be 2
    print $gsm->wop->{Rose};

    # Degree of seperation
    # Should be 2 (Marry -> Rose -> Joan)
    print $gsm->dos('Marry','Joan');
    # Should be less then zero (Unreachable)
    print $gsm->dos('Gugod','Marry');

    # all-pair dos (hashref of hashref)
    $gsm->all_dos;

DESCRIPTION

This module implement a interesting graph application that is called the 'Social Relation Map'. It provides object-oriented way to retrieve many social information that can be found in this map.

The new() constructor accepts one argument in the for of 'hashref of arrayref'. The key to this hash is the name of relation, and the value of the hash is a list of identities involved in this relation.

Take the synopsis for an example, the structure:

    my $relation = {
        1357 => [qw/Marry Rose/],
        3579 => [qw/Marry Peacock/],
        2468 => [qw/Joan/],
        4680 => [qw/Rose Joan/],
        OSSF => [qw/Gugod Autrijus/],
    };

Defines 6 relations which have common people involves in, the relation '1234' involves Marry and Rose, and the relation '3579' involves Marry and Peacock. By this 2 relations, we say that Marry is directly connected to Rose and Peacock, and Rose and Peacock are connected to each other indirectly, with degree of seperation 1. Likewise, Marry and Joan are connected to each other with degree of seperation 2.

TODO

So far the API really sucks, I will change them to be more canonical named.

COPYRIGHT

Copyright 2004 by Kang-min Liu <gugod@gugod.org>.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See <http://www.perl.com/perl/misc/Artistic.html>