igraph-help
[Top][All Lists]
Advanced

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

[igraph] Subgraph edges


From: Perrone, Alexander G.
Subject: [igraph] Subgraph edges
Date: Fri, 28 Oct 2016 20:45:11 +0000
User-agent: Microsoft-MacOutlook/14.6.9.160926

Maybe stupid question, but when using subgraph.edges using an index, it
returns the wrong edge and/or re-names the vertices. How do I get a
subgraph based on an index of the edges?

For a graph g, say I want to subgraph to the first edge, which in the case
below is 1–3. I try subgraph.edges(g, 1) but it returns the wrong edge. In
fact, it always returns the same edge (1–2) which makes me think it is
re-naming the vertices.

set.seed(1)
g <- sample_gnm(5, 5)
g
## IGRAPH U--- 5 5 -- Erdos renyi (gnm) graph
## + attr: name (g/c), type (g/c), loops (g/l), m (g/n)
## + edges:
##   [1] 1--3 2--3 1--4 1--5 4--5


subgraph.edges(g, 1)  # WANT to return 1–3
## IGRAPH U--- 2 1 -- Erdos renyi (gnm) graph
## + attr: name (g/c), type (g/c), loops (g/l), m (g/n)
## + edge:
##   [1] 1--2


sessionInfo()
R version 3.3.0 (2016-05-03)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11.6 (El Capitan)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] visNetwork_1.0.2   RColorBrewer_1.1-2 data.table_1.9.6   igraph_1.0.1
    

loaded via a namespace (and not attached):
 [1] htmlwidgets_0.6 Matrix_1.2-7.1  magrittr_1.5    htmltools_0.3.5
tools_3.3.0    
 [6] Rcpp_0.12.5     grid_3.3.0      jsonlite_0.9.20 digest_0.6.9
chron_2.3-47   
[11] lattice_0.20-33







reply via email to

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