Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- settle_gridlock_ver2<-function(list_of_graphs){
- SI=data.frame()
- for(graph in list_of_graphs){
- sqldf('drop table if exists complete_graph_table')
- list_of_strongly_connected_components=pruneLeaf(graph)
- complete_graph_table<-as_data_frame(graph)
- list_of_cycles<-Filter(function(x)vcount(x)>1,list_of_strongly_connected_components)
- sub_SI<-data.frame()
- for(subgraph in list_of_cycles){
- solution<-network_simplex(subgraph)[[3]]
- graph_table<-cbind(as_data_frame(subgraph),solution)
- result<-sqldf('select [from],[to],solution as Quantity, [Security Code] from graph_table')
- sub_SI<-rbind(sub_SI,result)
- sqldf('drop table sub_SI')
- sqldf('drop table graph_table')
- }
- excluded_SI=sqldf('select complete_graph_table.[from],complete_graph_table.[to],complete_graph_table.Quantity=0 as Quantity, complete_graph_table.[Security Code] from complete_graph_table left join sub_SI on sub_SI.[From]=complete_graph_table.[From] and sub_SI.[To]=complete_graph_table.[To] and sub_SI.[Security Code]=complete_graph_table.[Security Code] where sub_SI.Quantity is null ')
- SI<-rbind(SI,sub_SI,excluded_SI)
- }
- return(SI)
- }
- Error in sqliteSendQuery(con, statement, bind.data) :
- error in statement: table `graph_table` already exists
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement