krlawrence / graph

Practical Gremlin - An Apache TinkerPop Tutorial
Apache License 2.0
836 stars 253 forks source link

Question on subgraphs and associated traversal sources #191

Closed simonziegler closed 4 years ago

simonziegler commented 4 years ago

Hi Kelvin, this is an astonishingly good reference. Many thanks! If I create a subgraph and a traversal source for it, do I need to dispose of these somehow? And also if I have a query to create these that I use often from an app, should I give each subgraph a unique name, such as GUID? I am aiming to use Microsoft Cosmos DB.

Thanks, Simon

krlawrence commented 4 years ago

I'm not sure how Cosmos DB implements the subgraph step but in general what gets returned if using Java is a TinkerGraph object that you could potentially manipulate in memory. What exactly you get back will depend on the client language you use and the support provided by the back end GraphDB. The result may be as simple as a dict if you use the Python client for example. In either case you will just be working with local objects. The subgraph is not stored in the back end store as any sort of new persisted object. Does that help?

simonziegler commented 4 years ago

It does, thank you! What I get in .NET is indeed a dictionary of vertices and edges as you suggest. So can I just let the name of the subgraph go stale? Also, should I just do two queries: sg.V() and sg.E(), or is there a deft way to return both lists (I use the term very loosely) in one query?

Thanks, Simon

krlawrence commented 4 years ago

All you have there is a data structure. It is not connected in any way back to the graph it came from.

simonziegler commented 4 years ago

Thanks. At that stage the data structure is what I need. The graph (on the database) helps me navigate to the data that I require, which will comprise all vertices and nodes in a subgraph. My app will then workout the linkage based on the edge and the properties they contain. Will it be just a case of running two queries (sg.V() and sg.E()) once I have a subgraph traversal or can I do this in one query please?

Many thanks! Simon