Design Consideration

19 views
Skip to first unread message

Kalen Howell

unread,
Jun 4, 2012, 4:00:33 PM6/4/12
to gremli...@googlegroups.com
Greetings!

I'm looking to apply some 'dynamic weighting' to graph traversals.

For example:


DIST-MAP
dist : weight
1 : 10
2 : 8
3 : 6
4 : 4
5 : 2



NodeA -- related  --> NodeB  <-- related (distance 5) --  NodeC
NodeB  <-- related (distance 2) -- *NodeD
NodeB  <-- related (distance 1) --  NodeE

NodeA -- related  --> NodeH  <-- related (distance 2) -- *NodeD
NodeH  <-- related (distance 3) --  NodeG

During traversal I need to reference the DIST-MAP for the associated weight of the selected Node based on the distance to value and then store in another in-memory map:

NODE-WGT-MAP
 node : weight
 NodeC : 2
*NodeD : 16
 NodeE : 10
 NodeG : 6
 
Notice: *NodeD was traversed twice and the associated weights are summed in the NODE-WGT-MAP.

The final step is to sort the NODE-WGT-MAP from highest weight value to lowests and then return the map to the caller.

The above example has been greatly simplified from the real use case but the representation accurately reflects my problem space. 

The original hypothetical approach is to use Gremlin to do something like this:


1. Create a groovy closure to handle the adding of data to the map (if map.key exists; add new value to existing value; else, add new key/value)
2. Include map of dist/weight values
3. Write groovy script that would reference the closure (passing in the node(ID) and referenced weight) at the appropriate times when traversing the graph
4. append closure (1.), map (2.) with script (3.) in an Http Requests to Rexster
5. return the NODE-WGT-MAP

Final solution would involve storing DIST-MAP, groovy script(closure) server side (stored proc).


The above example implementation is purely hypythetical, and I'm looking for feedback and thoughts in the direction, or suggestions of different approaches.

Thanks for your consideration!

-Kalen
Reply all
Reply to author
Forward
0 new messages