Thanks a lot Darrick,
After getting the paths:
paths = person.out_e('ordered')
.in_v # items the person ordered
.in('ordered') # other people who ordered the same items
.out_e('ordered')
.in_v # other people's other ordered items
.paths
[#<V[73137]>, #<E[1087042]:73137-order_from-16307>, #<V[16307]>, #<E[1027533]:47744-order_from-16307>, #<V[47744]>, #<E[1027551]:47744-order_from-2582>, #<V[2582]>]
[#<V[73137]>, #<E[1087042]:73137-order_from-16307>, #<V[16307]>, #<E[1027533]:47744-order_from-16307>, #<V[47744]>, #<E[1027546]:47744-order_from-22650>, #<V[22650]>]
[#<V[73137]>, #<E[1087042]:73137-order_from-16307>, #<V[16307]>, #<E[962379]:20213-order_from-16307>, #<V[20213]>, #<E[962304]:20213-order_from-1836>, #<V[1836]>]
...
=> #<V-Index(remote_id: "{04192b83-058f-4ce4-a7f5-71ad75c75cf9}") -> outE(:order_from) -> inV -> inE(:order_from) -> outV -> outE(:order_from) -> where(weight > 9) -> inV -> Obj-Path>
Mapped out another path excluding elements 3,4,5:
mpaths = paths.map {|path| [path[0], path[1], path[2], path[6]] }
But how can we create an edge on the fly –without persisting into the database? If I can, then I would add it to path like this, right:
mpaths = paths.map {|path| [path[0], path[1], path[2], similarity_edge, path[6]] }
Then I can create the subgraph from the new paths:
subgraph = mpaths.subgraph
Getting close, but need some more help, thanks!
Burak
On Wednesday, March 21, 2012 12:21:28 AM UTC+2, Darrick Wiebe wrote:
Best for you to first look at how subgraph is implemented and basically copy/paste that method into your code and update it. Perhaps eventually I'll support some transformation in the subgraph method but I hadn't thought of it when implementing it.
Once you've got the subgraph code, all you need to do is grab an array composed of items 0, 1, 2, 6 and run the subgraph creation stuff on it then add in the edge between 2 and 6.
Cheers,
Darrick