igraph-help
[Top][All Lists]

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

 From: Gábor Csárdi Subject: Re: [igraph] Correlation based on the attributes of vertices Date: Wed, 5 Oct 2011 12:00:43 -0400

```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

```