Examples for 'igraph::igraph-es-indexing'


Indexing edge sequences

Aliases: igraph-es-indexing [.igraph.es %--% %<-% %->%

Keywords:

### ** Examples

# special operators for indexing based on graph structure
g <- sample_pa(100, power = 0.3)
E(g) [ 1:3 %--% 2:6 ]
+ 4/99 edges from 6dea7f0:
[1] 2->1 3->1 4->1 6->1
E(g) [ 1:5 %->% 1:6 ]
+ 4/99 edges from 6dea7f0:
[1] 2->1 3->1 4->1 5->4
E(g) [ 1:3 %<-% 2:6 ]
+ 4/99 edges from 6dea7f0:
[1] 2->1 3->1 4->1 6->1
# the edges along the diameter
g <- sample_pa(100, directed = FALSE)
d <- get_diameter(g)
E(g, path = d)
+ 12/99 edges from 0596c7e:
 [1] 73--78 65--73 52--65 16--52  4--16  1-- 4  1-- 2  2--12 12--13 13--28
[11] 28--76 76--99
# select edges based on attributes
g <- sample_gnp(20, 3/20) %>%
  set_edge_attr("weight", value = rnorm(gsize(.)))
E(g)[[ weight < 0 ]]
+ 19/35 edges from 7384f5e:
   tail head tid hid      weight
2     3    5   3   5 -0.35017023
3     3    7   3   7 -0.87215979
4     6    7   6   7 -0.36714232
5     3    8   3   8 -2.42851422
9     5    9   5   9 -1.12463882
12    6   10   6  10 -0.05277581
16    2   14   2  14 -0.55215345
18   11   14  11  14 -1.26055434
21    8   16   8  16 -0.86073117
22   11   16  11  16 -2.35266875
23   13   16  13  16 -0.52965699
25   11   17  11  17 -0.53642108
26    3   18   3  18 -0.67028960
27   12   18  12  18 -0.90878813
30   12   19  12  19 -0.24478941
32   11   20  11  20 -0.86791113
33   14   20  14  20 -0.38114551
34   16   20  16  20 -1.87950341
35   19   20  19  20 -1.13447978

[Package igraph version 1.3.1 Index]