Skip to content

Instantly share code, notes, and snippets.

@nawroth
Forked from dirkschumacher/gist:c0c1d78c721aa4fe2adc
Last active August 29, 2015 14:01
Show Gist options
  • Save nawroth/d482cc2da0bb4030c271 to your computer and use it in GitHub Desktop.
Save nawroth/d482cc2da0bb4030c271 to your computer and use it in GitHub Desktop.
= The news reads us data in Neo4J
Data by: http://newsreadsus.okfn.de/
== Intro
Interesting data created by http://newsreadsus.okfn.de/.
I converted the data from the links.json file and converted it into two simple csv files.
//setup
[source,cypher]
----
LOAD CSV FROM "https://dl.dropboxusercontent.com/s/riz5hp32mz0jzed/sites.csv?dl=1" AS csvline
MERGE (n:NewsSite { domain: csvline[0]})
MERGE (a:MetricService { domain: csvline[1]})
CREATE n-[:USES]->a
----
//setup
[source,cypher]
----
LOAD CSV FROM "https://dl.dropboxusercontent.com/s/fpbjo01j0bhek6v/networks.csv?dl=1" AS csvline
MERGE (c:Company { name: csvline[1]})
MERGE (a:MetricService { domain: csvline[0]})
CREATE c-[:OWNS]->a
----
== Some Numbers
=== Used metric services by news site
[source,cypher]
----
MATCH (n:NewsSite)-[:USES]->(a:MetricService)
Return n.domain AS NewsSite,count(a) as NoUsedMetricServices
ORDER BY NoUsedMetricServices DESC
----
//table
=== Number of owned metric services by company
[source,cypher]
----
MATCH (c:Company)-[:OWNS]->(a:MetricService)
Return c.name AS Company,count(a) as NoOfOwnedMetricServices
ORDER BY NoOfOwnedMetricServices DESC
----
//table
== To who news sites report
[source,cypher]
----
MATCH (n:NewsSite)-[:USES]->(a:MetricService)<-[:OWNS]-(c:Company)
Return n.domain as NewsSite,c.name as Company, count(a) As NoOfUsedMetricServicesOfThatCompany
ORDER BY NewsSite, Company, NoOfUsedMetricServicesOfThatCompany DESC
----
//table
== Small example: all services used by spiegel.de
(tried to display that as a graph, but the system always shows the full graph regardles of any where expressions)
[source,cypher]
----
MATCH (n:NewsSite {domain: "spiegel.de"})-[u:USES]->(a:MetricService)<-[o:OWNS]-(c:Company)
RETURN a, o, c
----
//graph_result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment