igraph-help
[Top][All Lists]

## Re: [igraph] Correlation based on the attributes of vertices

 From: S.M. Ali Abbas Subject: Re: [igraph] Correlation based on the attributes of vertices Date: Mon, 10 Oct 2011 12:38:10 +0100

Thank you very much! It does work.
I was thinking that perhaps this correlation on attribute list won't be relevant to my problem, as, for instance, dorm values are mere integer labels of random nature. Corr(x,y) does not take the variation in y values but also of x. If I get it right, it won't work for labels then. I should rather make a matrix for all the unique dorms m as (m x m matrix), and then populate each cell with the number of connections between them. After that, I should calculate correlation over it.

On Wed, Oct 5, 2011 at 5:00 PM, Gábor Csárdi wrote:
Hi,

On Mon, Oct 3, 2011 at 1:34 PM, S.M. Ali Abbas <address@hidden> wrote:
> Hi,
> I have a directed graph which has some vertices attributes (like dorm, year
> etc). Edges and the graph itself do not have any attributes. Based on the
> attributes of the vertices, I'd like to calculate correlation among the
> edges (e.g. how likely people of the same dorm are connected?) for the whole
> graph. Also, I'd like to calculate inter-attributes correlation for the
> whole graph (how correlated dorm and year attributes are?)
> Could you kindly tell how to go about it?

el <- get.edgelist(g, names=FALSE)
dorm <- matrix(nc=2, get.vertex.attribute(g, "dorm", el))

gives you the "dorm" for the vertices along each edge.

> I thought of populating a list just like the graph edge list, and then
> replacing each source and destination by its attribute value. For instance,
> instead of the edge (0->1), I will replace it by (dorm_valueOf(0) ->
> dorm_valueOf(1)) and then run the function cor over it. It does not seem
> like a nice solution.

Why not? Basically this is what I did above. You cannot run cor() on
this, though, cor() is for numeric data.

> On a side note, how does one get source and destination out of an edge list
> by the Edge Iterator?

See get.edge()

Cheers,
Gabor

> For example, I'd like to know the source and the
> target vertices' index of the first edge, E(graph)[0]. How can I extract
> this information?
>
> Thanks!
>
> Cheers,
> Ali
>
>
>
> _______________________________________________
> igraph-help mailing list
> https://lists.nongnu.org/mailman/listinfo/igraph-help
>
>

--
Gabor Csardi <address@hidden>     MTA KFKI RMKI

_______________________________________________
igraph-help mailing list