[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] An elementary question
From: |
Yiorgos Adamopoulos |
Subject: |
Re: [igraph] An elementary question |
Date: |
Thu, 30 Jun 2011 00:08:34 +0300 |
On Tue, Jun 28, 2011 at 6:12 PM, Moses Boudourides
<address@hidden> wrote:
> I'm sorry to bother you with such a trivial question but it would save
> me some time searching through manuals if you were able to give me
> directly the answer.
With my 1 month experience on igraph, I do not find your question a trivial one.
> Say I have a graph G and all vertices are associated to a binary
> attribute which takes the values 1 and 0, i.e., for each vertex the
> attribute is either 1 or 0.
Since I am not accustomed to igraph's attribute interface, I
constructed an array containing values of 0 and 1. I am indexing the
array using the vertex id.
> (1) G1 which is what it remains from G if we DELETE ALL LINKS
> connecting vertices with attribute 0 (but of course keeping in G1 all
> vertices of G, although some of them now might turn out to be
> isolated)?
Here is what I did. I constructed an Erdos-Renyi G(n,p) graph. From
this graph I got its adjacency matrix (m) which I copied to two other
matrices (m1 and m0).
I iterated through the vertices of the graph. If the attribute was 0,
then I zeroed the respective line and column in the new adjacency
matrix.
Some drawbacks in my approach that are seen immediately:
1- Isolated vertices are "lost". They can be restored by either
keeping them in a list, inserting a self-loop or some other hack.
2- It is written in C
3- It does not read a CSV. If the list can recommend a parser that
goes from CSV files to an igraph_t maybe this hack I did can improve.
--
http://gr.linkedin.com/in/yiorgos