Skip to content

Instantly share code, notes, and snippets.

@nicokosi
Last active December 21, 2015 07:56
Show Gist options
  • Save nicokosi/42831a8050aa748e43b2 to your computer and use it in GitHub Desktop.
Save nicokosi/42831a8050aa748e43b2 to your computer and use it in GitHub Desktop.
A Neo4J gistgraph (http://neo4j.com/graphgist) for a fake telco use case. Can be submitted on http://portal.graphgist.org/submit_graphgist.

Fake Telco

Let’s say that a ake telco needs to answer various questions such as:

  • contracts that are not used by any clients

  • etc…​

Setup graph:

CREATE
  (alice:Client {name: 'Alice'}),
  (bob:Client {name: 'Bob'}),
  (charly:Client {name: 'Charly'}),
  (contract3g:Contract {name: '3G'}),
  (contract5g:Contract {name: '5G'}),
  (contract50g:Contract {name: '50G'}),
  (nexus:Mobile {model: 'Nexus 42'}),
  (iphone:Mobile {model: 'Iphone 666'}),
  (alice)-[:HAS_A_SUBSCRIPTION_TO {since: 2014}]->(contract3g),
  (bob)-[:HAS_A_SUBSCRIPTION_TO {since: 2012}]->(contract5g),
  (charly)-[:HAS_A_SUBSCRIPTION_TO {since: 2015}]->(contract5g),
  (alice)-[:HAS_BOUGHT]->(nexus),
  (bob)-[:HAS_BOUGHT]->(iphone);

List of contracts without clients:

MATCH (contract:Contract)
WHERE NOT (:Client)-[:HAS_A_SUBSCRIPTION_TO]->(contract:Contract)
RETURN DISTINCT contract;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment