[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] Weighted adjacency matrix based on common nominal attribute
From: |
Moses Boudourides |
Subject: |
Re: [igraph] Weighted adjacency matrix based on common nominal attributes |
Date: |
Sat, 7 Jul 2012 09:16:47 +0300 |
Hi Alex,
First of all it depends on whether your relationships of friendship
are symmetrical (mutual) or not. If they are not, you may need to
explain what you mean by common friends.
If they are symmetrical, there is a simple matrix computation
answering your question. Denote by A the (symmetrical) matrix nxn
which registers who's friend to whom (the adjacency matrix). Then A^2
is what you need to find, i.e., a non-diagonal entry {A^2}ij signifies
the number of 2-paths connecting persons i and j which corresponds
exactly to the number of common friends of persons i and j. (Now, a
diagonal entry {A^2}ii is just twice the number of friends that person
i has.)
In the non-symmetrical case, if a person's list of friends is what,
for instance in Twitter, one understands as one's followers, then the
answer is given by the matrix product AA^T (where A^T is the transpose
of A), while if a person's friends are understood as other persons
that the former follows, then the answer is A^T A.
Of course, these are matrix computations and they might be quite time
consuming for very large matrices. I'm sure there is an equivalent
computation on lists of edges which if I remember well has been
already mentioned in this list server but I'm afraid I cannot locate
the mail.
Best,
--Moses
On Sat, Jul 7, 2012 at 4:10 AM, Alexander Semenov
<address@hidden> wrote:
> Hello everybody,
>
> I'm still a newbie to R and igraph, but not to Google (I hope), where I
> couldn't find the answer for my question.
>
> I have n persons (n = 43), each of which has a list of friends. I need to
> create a weigted adjacency matrix n X n, where the weights represent the
> amount of common friends of each person.
>
> Suppose I create 43 vectors (or lists ?) in R, what should I do next? I
> understand, that I should compare each list with one another, but that's all
> I can understand up to now.
>
> Thanks in advance!
>
> Best regards,
> Alex.
>
> P.S. Sorry for cross-post, as I've asked the same question in statnet
> listserv.
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/igraph-help
>