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 poi


From: Jose Quesada
Subject: Re: [igraph] subgraph by passing list of nodes that grabs also nodes pointing to that list
Date: Thu, 14 May 2009 08:28:19 +0200
User-agent: Thunderbird 2.0.0.21 (Windows/20090302)

Gábor Csárdi wrote:

Thanks Gabor,
> there are many ways to do this, perhaps the simplest is to use
> neighborhood() to collect the neighboring vertices and then call
> subgraph().
>
> vv <- neighborhood(g, order=1, nodes=mynodes, mode="in")
>   
hmm, this doesn't work on my network; it returns exactly the same list,
mynodes, with no additional ones.
I created the network by reading from a MatrixMarket file into a
CsparseMatrix object with readMM, then constructing the graph from that
matrix.

I'm attaching a toy example, and code to reproduce the problem:

library(igraph)
library(Matrix)

# Toy: just last few movies
dataMtxFile = "movies2actors-10-idsOnly.mtx"
# ma for movie actors
matoy = as(readMM(paste(datapath, dataMtxFile, sep="")), "CsparseMatrix")
tg = graph.incidence(matoy, directed=T, mode="out")
mynodes =  1377253
vv <- neighborhood(tg, order=1, nodes=mynodes, mode="in")
vv
#> vv
#[[1]]
#[1] 1377253 <- lists only the original node; misses five inbound
connections.
vv <- neighborhood(tg, order=1, nodes=mynodes, mode="all") #same for out
vv # this lists all nodes but the ones that are actually connected to
1377253
# [[1]]
#  [1] 1377253 1413423 1457015 1464520 1517383 1641295 1704978 1741976
1744269 1744274 1744315 1745028 1745031 1756801 1783566
# [16] 1803739 1836911 1836953 1836954 1836964 1836967 1844560 1848929
1880207 1946456 2132881 2203538 2278148 2282809 2324406
# [31] 2409592 2409595 2410120 2410900 2681118 2946503 2946504 2946655
2974742

What am I doing wrong?

Thanks!
-Jose
> subgraph(g, unique(unlist(vv)))
>
> Best,
> Gabor
>   


-- 
Jose Quesada, PhD.
Max Planck Institute,
Center for Adaptive Behavior and Cognition -ABC-, 
Lentzeallee 94, office 224, 14195 Berlin
http://www.josequesada.name/           

%%MatrixMarket matrix coordinate real general           
1377259 1646757 11463075                
1377251 368598  1
1377251 376496  1
1377251 507992  1
1377251 1022529 1
1377251 368598  1
1377251 376496  1
1377251 507992  1
1377251 1022529 1
1377251 1455334 1
1377251 1461807 1
1377251 1504970 1
1377252 152267  1
1377252 909337  1
1377252 1015503 1
1377252 152267  1
1377252 909337  1
1377252 1015503 1
1377252 1334333 1
1377253 331061  1
1377253 965696  1
1377253 331061  1
1377253 965696  1
1377253 1559936 1
1377254 36165   1
1377254 79757   1
1377254 87262   1
1377254 140125  1
1377254 264037  1
1377254 327720  1
1377254 364718  1
1377254 367011  1
1377254 367016  1
1377254 367057  1
1377254 367770  1
1377254 367773  1
1377254 379543  1
1377254 406308  1
1377254 426481  1
1377254 459653  1
1377254 459695  1
1377254 459696  1
1377254 459706  1
1377254 459709  1
1377254 467302  1
1377254 471671  1
1377254 502949  1
1377254 569198  1
1377254 755623  1
1377254 826280  1
1377254 900890  1
1377254 905551  1
1377254 947148  1
1377254 1032334 1
1377254 1032337 1
1377254 1032862 1
1377254 1033642 1
1377254 36165   1
1377254 79757   1
1377254 87262   1
1377254 140125  1
1377254 264037  1
1377254 327720  1
1377254 364718  1
1377254 367011  1
1377254 367016  1
1377254 367057  1
1377254 367770  1
1377254 367773  1
1377254 379543  1
1377254 406308  1
1377254 426481  1
1377254 459653  1
1377254 459695  1
1377254 459696  1
1377254 459706  1
1377254 459709  1
1377254 467302  1
1377254 471671  1
1377254 502949  1
1377254 569198  1
1377254 755623  1
1377254 826280  1
1377254 900890  1
1377254 905551  1
1377254 947148  1
1377254 1032334 1
1377254 1032337 1
1377254 1032862 1
1377254 1033642 1
1377254 1303860 1
1377254 1569245 1
1377254 1569246 1
1377254 1569397 1
1377254 1597484 1
1377256 87500   1
1377256 183162  1
1377256 364738  1
1377256 364770  1
1377256 406416  1
1377256 406417  1
1377256 459637  1
1377256 495809  1
1377256 503086  1
1377256 503107  1
1377256 569829  1
1377256 786113  1
1377256 806664  1
1377256 854114  1
1377256 1063933 1
1377256 1229901 1
1377256 87500   1
1377256 183162  1
1377256 364738  1
1377256 364770  1
1377256 406416  1
1377256 406417  1
1377256 459637  1
1377256 495809  1
1377256 503086  1
1377256 503107  1
1377256 569829  1
1377256 786113  1
1377256 806664  1
1377256 854114  1
1377256 1063933 1
1377256 1229901 1
1377256 1249185 1
1377256 1250414 1
1377256 1286723 1
1377256 1483931 1
1377256 1493639 1
1377256 1511249 1
1377256 1541573 1
1377256 1559434 1
1377258 43101   1
1377258 187342  1
1377258 959054  1
1377258 43101   1
1377258 187342  1
1377258 959054  1
1377259 137335  1
1377259 508942  1
1377259 137335  1
1377259 508942  1

reply via email to

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