-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmy_igraph_function.R
More file actions
executable file
·53 lines (46 loc) · 1.29 KB
/
my_igraph_function.R
File metadata and controls
executable file
·53 lines (46 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
remove_edges_between_nodes_by_properties = function(g, name="type",value1 = "nano", value2 = "nano",list_vertices= NULL){
if(name =="type"){
if(is.null(list_vertices)){
list1 = V(g)[which(V(g)$type %in% value1)]$name
list2 = V(g)[which(V(g)$type %in% value2)]$name
}else{
list1 = V(g)[which(V(g)$type %in% value1)]$name
list2 = list_vertices
}
}else{
warning("This is not a vertex attribute")
return()
}
for(ni in list1){
for(nj in list2){
if(ni != nj){
idx = get.edge.ids(graph = g,vp = c(ni,nj))
if(idx!=0){
g = delete.edges(graph = g,edges = paste(ni,"|",nj,sep=""))
}
}
}
}
return(g)
}
print_informazione = function(g, name="weight",value1 = "nano", value2 = "nano",list_vertices= NULL){
if(is.null(list_vertices)){
list1 = V(g)[which(V(g)$type %in% value1)]$name
list2 = V(g)[which(V(g)$type %in% value2)]$name
}else{
list1 = V(g)[which(V(g)$type %in% value1)]$name
list2 = list_vertices
}
for(ni in list1){
for(nj in list2){
if(ni != nj){
idx = get.edge.ids(graph = g,vp = c(ni,nj))
if(idx!=0){
w = get.edge.attribute(g,name = name,index = idx)
cat(ni," ",nj," ",w,"\n")
}
}
}
}
#return(g)
}