[ 
https://issues.apache.org/jira/browse/TINKERPOP-1234?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15215969#comment-15215969
 ] 

Daniel Kuppitz commented on TINKERPOP-1234:
-------------------------------------------

Looks very good. IntelliJ's debugger was making fun of me, but switching to 
{{System.out.println}} debugging solved all problems. Good stuff.
Question: Do we want {{CollaborativeFilterVertexProgram}} be part of TinkerPop?

Here's how it looks:

{code}
final Graph graph = TinkerFactory.createModern();
graph.vertices(1).next().addEdge("created", graph.vertices(5).next());
final GraphTraversalSource g = graph.traversal().withComputer();
g.V().as("a").out("created").in("created").where(neq("a")).
  
program(CollaborativeFilterVertexProgram.build().from("a").limit(10).property("cf").create(graph)).
  dedup().valueMap().forEachRemaining(System.out::println);
{code}

Result:

{noformat}
{cf=[{4=2, 6=1}], name=[marko], age=[29]}
{cf=[{1=1, 4=1}], name=[peter], age=[35]}
{cf=[{1=2, 6=1}], name=[josh], age=[32]}
{noformat}

The {{cf}} property contains a map of the 10  highest weighted co-workers of 
each person (map key is the id of the other person, map value is the count / 
weight):

* marko's co-workers: josh (id: 4, weight: 2), peter (id: 6, weight: 1)
* peter's co-workers: marko (id: 1, weight: 1), josh (id: 4, weight: 1)
* josh's co-workers: marko (id: 1, weight: 2), peter (id: 6, weight: 1)

> program() step that takes arbitrary vertex programs
> ---------------------------------------------------
>
>                 Key: TINKERPOP-1234
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-1234
>             Project: TinkerPop
>          Issue Type: Improvement
>          Components: process
>    Affects Versions: 3.2.0-incubating
>            Reporter: Daniel Kuppitz
>            Assignee: Marko A. Rodriguez
>
> In 3.2 VertexPrograms like {{PageRankVertexProgram}} will have a dedicated 
> step that allows to do things like {{g.V().out().out().pageRank()}}. Would be 
> nice to have a general step {{program()}}, so that we can do the same thing 
> with any {{VertexProgam}}, e.g.
> {code}
> // pre-calculate "users who bought this, also bought" and create uwbt-edges 
> for the top 100 results per vertex
> g.V().as("a").in("bought").out("bought").where(neq("a")).as("b").select("a","b").
>   
> program(CollaborativeFilterVertexProgram.build().source("a").target("b").limit(100).edgeLabel("uwbt").weightProperty("weight").create())
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to