igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] An elementary question


From: Gábor Csárdi
Subject: Re: [igraph] An elementary question
Date: Thu, 30 Jun 2011 15:31:35 -0400

Moses,

On Tue, Jun 28, 2011 at 11:12 AM, Moses Boudourides
<address@hidden> wrote:
> Hello,
>
> 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.
>
> 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.
>
> How would I get in igraph the following two graphs:
>
> (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)?

delete.edges(g, E(g)[ V(g)[attr == 0] %--% V(g)[attr == 0] ])

'g' is the graph, 'attr' is the name of the attribute. This might not
be the fastest to run, but it should work. (Tell me if it does not.)

> (2) G0 which is what it remains from G if we delete all links
> connecting vertices with attribute 1 (but of course keeping all
> vertices of G)?

Similarly,

delete.edges(g, E(g)[ V(g)[attr == 1] %--% V(g)[attr == 1] ])

G.

> Best,
>
> --Moses
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/igraph-help
>



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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]