sorry I'm rather new to this igraph package Right now I'm having a non-simple cycle, and I'm trying to simplify the cycle by going through every node and delete edges that meet certain criteria. I have been working on this problem for a couple of hours and would appreciate some suggestion to solve this problem.
Right now I am working on a function, given the vertex of a graph, then we want to eliminate all edges with length less than the maximum length of all these edges from that particular vertex
df=data.frame(node("A","A","B","B","A"),edge("B","C","C","A","B"),length(1,1,1,1,10))
g<-graph_from_data_frame(df)
delete_extra_edges<-function(g,node){
list_of_incident_edges=incident_edges(g,node,"out")
max_quantity<-max(unlist(list_of_incident_edges[[1]]$length))
list_to_delete=which(list_of_incident_edges[[1]]$length<max_quantity)
for(index in list_to_delete){
g<-delete_edges(g,index) #or alternatively: g<-g-list_of_incident_edges[[1]][index]
}
return(g)
}
The problem with this method is that (other than the fact it will still retain multiple edges that have the same length as the maximum length, but I will deal with that later), the index of the list_to_delete does not necessarily equate the edge ID in the graph g.
The problem with the alternative implementation is that it gives me the "Cannot use an edge from another graph" error
I am just working with a test data frame df as defined above