Commit 4b8751cb by TJBChris

Modified search walker to not return edges on the last depth level of a

crawl.
parent 58b52738
...@@ -90,36 +90,38 @@ public class GraphBackedDiscoveryService implements DiscoveryService { ...@@ -90,36 +90,38 @@ public class GraphBackedDiscoveryService implements DiscoveryService {
// Add to the Vertex map. // Add to the Vertex map.
v.put(vtx.getId().toString(), new JSONObject(jsonVertexMap)); v.put(vtx.getId().toString(), new JSONObject(jsonVertexMap));
// Follow this Vertex's edges // Follow this Vertex's edges if this isn't the last level of depth
while (edgeIterator != null && edgeIterator.hasNext()) { if (counter < max) {
while (edgeIterator != null && edgeIterator.hasNext()) {
Edge edge = edgeIterator.next();
String label = edge.getLabel(); Edge edge = edgeIterator.next();
String label = edge.getLabel();
Map<String,String> jsonEdgeMap = new HashMap<>();
String tail = edge.getVertex(Direction.OUT).getId().toString(); Map<String,String> jsonEdgeMap = new HashMap<>();
String head = edge.getVertex(Direction.IN).getId().toString(); String tail = edge.getVertex(Direction.OUT).getId().toString();
String head = edge.getVertex(Direction.IN).getId().toString();
jsonEdgeMap.put("tail", tail);
jsonEdgeMap.put("head", head); jsonEdgeMap.put("tail", tail);
jsonEdgeMap.put("label", label); jsonEdgeMap.put("head", head);
jsonEdgeMap.put("label", label);
Direction d;
if (tail.equals(vtx.getId().toString())) { Direction d;
d = Direction.IN; if (tail.equals(vtx.getId().toString())) {
} else { d = Direction.IN;
d = Direction.OUT; } else {
} d = Direction.OUT;
}
/* If we want an Edge's property keys, uncomment here. Or we can parameterize it.
* Code is here now for reference/memory-jogging. /* If we want an Edge's property keys, uncomment here. Or we can parameterize it.
for (String pKey: edge.getPropertyKeys()) { * Code is here now for reference/memory-jogging.
jsonEdgeMap.put(pKey, edge.getProperty(pKey).toString()); for (String pKey: edge.getPropertyKeys()) {
} jsonEdgeMap.put(pKey, edge.getProperty(pKey).toString());
*/ }
*/
e.put(edge.getId().toString(), new JSONObject(jsonEdgeMap));
searchWalker (edge.getVertex(d), max, counter, e, v, edgesToFollow); e.put(edge.getId().toString(), new JSONObject(jsonEdgeMap));
searchWalker (edge.getVertex(d), max, counter, e, v, edgesToFollow);
}
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment