how to produce the output

49 views
Skip to first unread message

Abhi

unread,
Sep 12, 2013, 5:03:53 AM9/12/13
to gremli...@googlegroups.com
Hi,

Attached is my graph.xml file.

How to fetch only buy and sell edges with complete vertexname and amount.

like :
 saler saler buyer amount

my current output is :

  • gremlin> g.v(0).outE().inV().bothE().path
  • ==> [v[0], e[4][0-Parent->1], v[1], e[4][0-Parent->1]]
  • ==> [v[0], e[4][0-Parent->1], v[1], e[7][3-Buy->1]]
  • ==> [v[0], e[4][0-Parent->1], v[1], e[6][1-Sell->3]]
mygraph.xml

Abhi

unread,
Sep 12, 2013, 5:09:12 AM9/12/13
to gremli...@googlegroups.com
now my output is :

but stiiil I need to print as:

saler saler Buyer Amount
------

here if I select v(0) as saler then it should print the corresponding saler and buyer and amount for that row. reverse may be possible.

  • gremlin> g.v(0).outE().inV().bothE('Buy','Sell')
  • ==> e[7][3-Buy->1]
  • ==> e[6][1-Sell->3]
  • gremlin> 

Abhi

unread,
Sep 12, 2013, 5:19:11 AM9/12/13
to gremli...@googlegroups.com
it shoukd be :

ParentSaler      Saler      Buyer     Amount
----------------     ---------    ---------    --------- 
      CP                  CP           ANZ       100
      CP                 ANZ           CP        200

now it is :

  • gremlin> g.v(0).outE().inV().bothE('Buy','Sell').path{it.name}{it.amount}
  • ==> [CP, null, CP, 200]
  • ==> [CP, null, CP, 100]
  • gremlin> 

Abhi

unread,
Sep 12, 2013, 7:58:12 AM9/12/13
to gremli...@googlegroups.com
now my query as follows:

I need this as final output :
[transaction: 100, saler : ANZ, buyer:CP]
[transaction: 200, saler : CP, buyer:ANZ]

any help ?

  • gremlin> g.v(0).outE().as('transaction').inV().bothE('Sell','Buy').inV().as('buyer').select{[it.amount]}{it.name}
  • ==> [transaction:[null], buyer:CP]
  • ==> [transaction:[null], buyer:ANZ]

Stephen Mallette

unread,
Sep 12, 2013, 8:05:56 AM9/12/13
to gremli...@googlegroups.com
Abhi, please try to work your problem a bit further along before asking for help.  I'm glad you are making progress, but it makes it hard to answer your questions when they come in lots of emails one after another.  

The reason your getting a null there for the "transaction amount" is because according to your data, g.v(0).outE.amount does not exist...in other words there is no "amount" property on that edge (that edge is a "Parent" edge, not a "Sell" or "Buy" edge.

Thanks,

Stephen


--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Abhi

unread,
Sep 12, 2013, 8:11:05 AM9/12/13
to gremli...@googlegroups.com
yes Stephen you are right. Thanx. sorry for spamming mails . I changed my query and get the transaction info. only thing i have to show the outV() means left vertex as seler. am working on it.  :)
 

  • gremlin> g.v(0).outE().inV.bothE('Sell','Buy').as('transaction').inV.as('buyer').select{[it.amount]}{it.name}
  • ==> [transaction:[200], buyer:CP]
  • ==> [transaction:[100], buyer:ANZ]
  • gremlin> 

Abhi

unread,
Sep 12, 2013, 10:02:54 AM9/12/13
to gremli...@googlegroups.com
unable to solve. I know the problem is behind first inV() while creating vertex. while executing the first row in the result is ok. but when iterating to next outE().inV..it again fetch node CP which should be ANZ this time. buyer side is working fine.

  • gremlin> g.v(0).outE().inV.as('supplier').bothE('Sell','Buy').as('tx_amount').inV.as('buyer').select{it.name}{it.amount}{it.name}.sort{it[2]}
  • ==> [supplier:CP, tx_amount:100, buyer:ANZ]
  • ==> [supplier:CP, tx_amount:200, buyer:CP]

Daniel Kuppitz

unread,
Sep 15, 2013, 7:19:23 AM9/15/13
to gremli...@googlegroups.com
Abhi,

there's only 1 outgoing edge from g.v(0). Why do you expect another "supplier"?

gremlin> g.v(0).outE
==>e[4][0-Parent->1]

Cheers,
Daniel

A Garg

unread,
Sep 16, 2013, 1:45:45 AM9/16/13
to gremli...@googlegroups.com
yes daniel you are right. I know the problem. But I want to show both supplier and buyer for a particular selected node. See in my case buyer is changing because of bothE()...Any otherway is it posible like using loop or back(?) or ifelsethen condition or reverse concept.

like if(bothE('Sell')) {
               print [ supplier = left node , buyer = right node ]
       } else {
               print [ supplier = right node, buyer = left node ]
       }

thanks .



A Garg

unread,
Sep 19, 2013, 4:58:39 AM9/19/13
to gremli...@googlegroups.com
I did it by placing headCustomerName as root and then define a child_rel between headCustomer and childcustomer. 

g.V.has("headCustomerName","ABC Corp.").inE('child_rel').outV().as('buyer').outE('Sell_To').as('tx_amount').inV().as('seller')  \
      .select{it.customerName}{it.amount}{it.customerName}  
==>[buyer:CP, tx_amount:100, seller:ANZ]
==>[buyer:CP, tx_amount:200, seller:SS Tech]
==>[buyer:SAK Corp., tx_amount:400, Supplier:AB Infotech]
...

and ,

g.V.has("headCustomerName","ABC Corp.").inE('child_rel').outV().as('seller').inE('Sell_To').as('tx_amount').outV().as('buyer')    \
      .select{it.customerName}{it.amount}{it.customerName}  
==>[seller:CP, tx_amount:1100, buyer:NEW Int]
==>[seller:CP, tx_amount:1300, buyer:Marry Gold]
==>[seller:SAK Corp., tx_amount:1006, buyer:LLI Corp.]
...

Thanks. :)
Reply all
Reply to author
Forward
0 new messages