Question

I have following graph

   Vertex v1 = g.addVertex(null);
   Vertex v2 = g.addVertex(null);
   Vertex v3 = g.addVertex(null);
   v1.addEdge("v1v2", v2);
   v2.addEdge("v2v3", v3);

If I remove v2 vertex, v1v2 v2v3 edge is deleted but v1 v3 vertex remain in graph. Will I have to remove v1 and v3 manually?

If I add another vertex:

Vertex v4 = g.addVertex(null);
v3.addEdge("v3v4", v4);

Vertex v5 = g.addVertex(null);
v5.addEdge("v5v3", v3);

Now If I will delete v1 all vertices should be deleted. How to do that? Does titan provide something for this?

Was it helpful?

Solution

Titan doesn't provide anything that can detect orphaned vertices. You will have to write your own approach to doing so. I suppose you have at least two ways to deal with them.

  1. If there's no harm in just leaving them there based on your schema/application, then let them remain orphaned. Then batch remove them with Faunus or some other script.

  2. Make removal of a v2 in your first example, part of a transaction that does some quick edge checks on v1 and v3. If neither of those have edges then remove those vertices as well.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top