简体   繁体   中英

How can I display the edges between vertices in IBM Graph?

I am able to successfully build vertices in IBM Graph, but when I execute query, output doesn't show the edges between vertices. I am running following code:

def v1 = graph.addVertex("name", "Darshit", label, "Inventorymanager","zip","95112"); 
def v2 = graph.addVertex("name", "Vikas", label, "Vendor","zip","95112"); 
def v3 = graph.addVertex("name", "Sidharth", label, "Vendor","zip","95112"); 
def v4 = graph.addVertex("name", "iPhone7", label, "Item","price",750,"quantity",10); 
def v5 = graph.addVertex("name", "chair", label, "Item","price",20,"quantity",15); 
def v6 = graph.addVertex("name", "laptop", label, "Item","price",800,"quantity",3);  
v1.addEdge("ordered_to", v2); 
v1.addEdge("ordered_to", v3); 
v2.addEdge("has", v4); 
v3.addEdge("has", v5); 
v2.addEdge("has", v6); 
v3.addEdge("has", v6);    
def g = graph.traversal(); 
g.V().has("name", "Darshit").out("ordered_to").has("name", "Vikas").path();

Change your query to

g.V().has("name", "Darshit").outE("ordered_to").inV().has("name", "Vikas").path();

That'll get you the edges as well

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM