igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] subgraph by passing list of nodes that grabs also nodes po


From: Gábor Csárdi
Subject: Re: [igraph] subgraph by passing list of nodes that grabs also nodes pointing to that list
Date: Sat, 20 Jun 2009 13:01:20 +0200

On Sat, Jun 20, 2009 at 11:39 AM, Jose Quesada <address@hidden> wrote:
[...]
>
> vv <- neighborhood(g, order=1, nodes=mynodes, mode="in")
> subgraph(g, unique(unlist(vv)))
>

The problem with this solution is that it doesn't keep the edges.
Subgraph returns only the vertices. I cannot think of a case where I'd
need the vertices and not the edges.
Is there any way to do what subgraph does, but keeping the edges?

I am not sure what you mean about not keeping the edges. 'subgraph' calculates in fact the induced subgraph of the given vertices, and it certainly keeps the edges:

> library(igraph)
> g <- graph.full(10)
> g2 <- subgraph(g, 0:4)
> summary(g2)
Vertices: 5
Edges: 10
Directed: FALSE
No graph attributes.
No vertex attributes.
No edge attributes.

G.
 
[...]

--
Gabor Csardi <address@hidden>     UNIL DGM


reply via email to

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