1

I want to keep all the browse history,

To calculate the behaviour among browsing pages.

So I designed the following graph to show my idea,

As you can see, there are 4 edges between page A and page B,

So how could I create the kind of relationships and nodes ?

how could I get the

  • average browsing time (20min)
  • min browsing time
  • max browsing time

Any suggestion and ideas?

Thanks

newBike
  • 14,385
  • 29
  • 109
  • 192
  • Your design could do with a rework. I'd say the best way is to have a 'Browsing' node in-between the page nodes, which you store the times on. Designing it like you have limits considerably the type of queries which you can perform on your graph – joe Jun 01 '15 at 14:06
  • did you mean each browse request should have a new node ? how does the node represents from pageA to pageB with the duration time. i'm new to neo4j, just couln't understand it. – newBike Jun 01 '15 at 14:58
  • The 'Browse' node would have an attribute 'Duration' which would contain the time. In Cypher you could use create (p1:Page {Name: "Page1"})-[:from]->(b:Browse {Duration: 10})-[:to]->(p2:Page {Name: "Page2"}) return p1,p2 – joe Jun 01 '15 at 15:07

1 Answers1

1

I'm a bit confused. What does the relationship mean? Does it represent the amount of time spent on page A before the user browses to page B?

Just going from your model and your goals, maybe something like this would work?

MATCH (a:Page)-[r:browsed_to]->(b:Page)
RETURN avg(r.time_spent)

For min and max time you could replace avg with min and max

Brian Underwood
  • 10,746
  • 1
  • 22
  • 34
  • yes, it is what you mean, so How could I create the kind of relationship between pages ? just create a relationship edge for each browse action ? – newBike Jun 01 '15 at 14:57
  • Yeah, you could certainly do that with `MATCH ... CREATE start-[:browsed_to {time_spent: {time_spent_param}}]->end`. I'm not sure of your use case, but it might be useful instead to have nodes be the visits. So you could have `(:Visit)-[:NEXT_VISIT]->(:Visit)` and `(:Visit)-[:AT_URL]->(:URL)` where `Visit` nodes would have the `time_spent` and `URL` nodes would have something like a `address` property which has a unique constraint – Brian Underwood Jun 01 '15 at 15:13