Your graph has vertex names, so igraph adds the vertex names to the output of degree():
g <- graph.ring(10) degree(g) # [1] 2 2 2 2 2 2 2 2 2 2 V(g)$name <- letters[1:10] degree(g) # a b c d e f g h i j # 2 2 2 2 2 2 2 2 2 2 If you want to omit the names entirely from the graph, then remove the "name" vertex attribute. If you don't want to add vertex names to results of any vertex indices, then set the "add.vertex.names" igraph option to FALSE: igraph.options(add.vertex.names=FALSE) degree(g) # [1] 2 2 2 2 2 2 2 2 2 2 Gabor On Wed, Mar 12, 2014 at 4:19 AM, Thomas <[email protected]>wrote: > Can anyone please explain why this is happening? With two different > graphs, the output format from degree() is different. I'd like to force the > second format (output just one number) on the first graph. > > Thank you, > > Thomas Chesney > > i <- 5 > > g <- read.table("/Users/thomas/Documents/Datasets/ > organizations/S1Anonymized.csv",header=FALSE, sep=",", na.strings="NA", > dec=".", strip.white=TRUE) > g <- graph.data.frame(g, directed=FALSE, vertices=NULL) > > degree(g,i) > 69 > 1 > > f <- watts.strogatz.game(1, 165, 5, 0.05) > degree(f,i) > [1] 8 > > str(degree(g,i)) > Named num 1 > - attr(*, "names")= chr "69" > > str(degree(f,i)) > num 8 > > I'm using R: > > > sessionInfo() > R version 2.15.3 (2013-03-01) > Platform: i386-apple-darwin9.8.0/i386 (32-bit) > > locale: > [1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8 > > attached base packages: > [1] stats graphics grDevices utils datasets methods base > > other attached packages: > [1] igraph_0.6.5-1 > > loaded via a namespace (and not attached): > [1] tools_2.15.3 > > This message and any attachment are intended solely for the addressee and > may contain confidential information. If you have received this message in > error, please send it back to me, and immediately delete it. Please do > not use, copy or disclose the information contained in this message or in > any attachment. Any views or opinions expressed by the author of this > email do not necessarily reflect the views of the University of Nottingham. > > This message has been checked for viruses but the contents of an attachment > may still contain software viruses which could damage your computer > system, you are advised to perform your own checks. Email communications > with the University of Nottingham may be monitored as permitted by UK > legislation. > > > > > > _______________________________________________ > igraph-help mailing list > [email protected] > https://lists.nongnu.org/mailman/listinfo/igraph-help >
_______________________________________________ igraph-help mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/igraph-help
