You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
autograders/neo4j/source/solution.py

74 lines
2.9 KiB

sols = [
'''
MATCH (author:Author)-[:WRITES]->(article:Article)
RETURN author.name, article.title
''',
('''
match (author:Author)-[:WRITES]->(paper_or_chapter)
return author.name, paper_or_chapter.title, labels(paper_or_chapter)
''',
'''
MATCH (author:Author)-[:WRITES]->(paper_or_chapter)
WITH author, paper_or_chapter, labels(paper_or_chapter) as publicationType
WHERE publicationType=["Article"] or publicationType=["Chapter"]
RETURN author.name, paper_or_chapter.title, publicationType
'''),
('''
match (author:Author)-[:WRITES|EDITS]->(publication)
return author.name, publication.title, labels(publication)
''',
'''
MATCH (author:Author)-[]->(publication)
WHERE publication:Article or publication:Chapter or publication:Book
RETURN author.name, publication.title, labels(publication)
'''),
('''
match (author:Author)-[:WRITES|EDITS]->(publication)
return author.name, count(publication) as publication_count
''',
'''
MATCH (author:Author)-[]->(publication)
WHERE publication:Article OR publication:Chapter or publication:Book
RETURN author.name, count(publication) as publication_count
'''),
('''
match(a:Article)-[in:IN]->(:Issue)
where (in.pp[1] - in.pp[0]) <= 10
return a.title, (in.pp[1] - in.pp[0] + 1) as NumberOfPages
''',
'''
MATCH (a:Article)-[e:IN]->(:Issue)
WITH a, e.pp[1]-e.pp[0]+1 as NumberOfPages
WHERE NumberOfPages <=10
RETURN a.title, NumberOfPages
'''),
'''
MATCH (p2:Article)<-[]-(a1:Author)-[]->(p1:Article),(p1)-[:CITES]->(p2)
RETURN a1.name, p1.title, p2.title
''',
'''
MATCH (publication)<-[:CITES]-()
WITH publication, count(*) as publication_count
WHERE (publication:Article or publication:Chapter) and publication_count >= 2
RETURN publication.title, publication_count
''',
('''
match (journal:Journal)<-[:OF]-(issue:Issue)<-[:IN]-(article:Article)<-[:CITES]-(someOtherPublication)
with journal, article, count(someOtherPublication) as citations_count
where citations_count > 1
match (article)<-[:WRITES]-(author:Author)
return journal.title, article.title, citations_count, author.name
''',
'''
MATCH (author:Author)-[:WRITES]->(article:Article)-[:IN]->()-[]->(journal:Journal), ()-[e:CITES]->(article:Article)
WITH journal, article, author, count(e) as citation_count
WHERE citation_count >= 2
RETURN journal.title, article.title, citation_count, author.name
'''),
'''
MATCH (a1:Article)-[:IN]->(i1:Issue)-[]->(:Journal)<-[]-(i2:Issue)<-[]-(a2:Article)
WHERE (a1)-[:CITES]->(a2)
RETURN a1.title, i1.issue, a2.title, i2.issue
'''
]