Advertisement
Guest User

Untitled

a guest
May 26th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. settle_gridlock_ver2<-function(list_of_graphs){
  2. SI=data.frame()
  3. for(graph in list_of_graphs){
  4. sqldf('drop table if exists complete_graph_table')
  5. list_of_strongly_connected_components=pruneLeaf(graph)
  6. complete_graph_table<-as_data_frame(graph)
  7. list_of_cycles<-Filter(function(x)vcount(x)>1,list_of_strongly_connected_components)
  8. sub_SI<-data.frame()
  9. for(subgraph in list_of_cycles){
  10. solution<-network_simplex(subgraph)[[3]]
  11. graph_table<-cbind(as_data_frame(subgraph),solution)
  12. result<-sqldf('select [from],[to],solution as Quantity, [Security Code] from graph_table')
  13. sub_SI<-rbind(sub_SI,result)
  14. sqldf('drop table sub_SI')
  15. sqldf('drop table graph_table')
  16. }
  17. 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 ')
  18. SI<-rbind(SI,sub_SI,excluded_SI)
  19. }
  20.  
  21. return(SI)
  22. }
  23. Error in sqliteSendQuery(con, statement, bind.data) :
  24. error in statement: table `graph_table` already exists
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement