0

I am building an asp.net MVC application which searches a graph data structure to fulfill user's requests. I want to build this graph data structure on first request from database and then on requests after first request I want to use the previously built graph rather than building it again.

but I do not know where to store the graph on first request so it can be accessed on subsequent requests.

Ali Shan
  • 459
  • 7
  • 14

1 Answers1

1

I think you could consider storing it in your DB, and this would require you to store your graph in two separate tables: one for Nodes and one for Paths. You should have start_node_id and end_node_id in Paths, both being foreign keys referring to Nodes. As nodes can be connected with variable numbers of nodes, I believe creating multiple columns referring neigbouring nodes in Nodes makes no sense at all, as it would mean lots of NULL neighbours and limiting maximum neighbours count.

  • i do not want to built the graph in db. the graph should be loaded in memory to run search on it – Ali Shan Dec 30 '16 at 17:50
  • 1
    Do you want your graph to exist as long as session is not terminated only? If so, you may find [this](http://stackoverflow.com/questions/560084/session-variables-in-asp-net-mvc) thread interesting. –  Dec 30 '16 at 17:57