Skip to content

Instantly share code, notes, and snippets.

@carlasanches
Last active April 30, 2023 01:44
Show Gist options
  • Save carlasanches/c46246e2d9ae9c1e88878970537f9df8 to your computer and use it in GitHub Desktop.
Save carlasanches/c46246e2d9ae9c1e88878970537f9df8 to your computer and use it in GitHub Desktop.
# Create extension
CREATE EXTENSION age;
# Load extension
LOAD 'age';
# Add ag_catalog to search_path
SET search_path = ag_catalog, "$user", public;
# Create the graph
SELECT * FROM create_graph('citation_graph');
# Create all vertices
SELECT * FROM cypher('citation_graph', $$
CREATE (v:Article {id: 'williams2015affect', title: 'Investigating affect in algorithmic composition systems', publisher: 'Psychology of Music',year: 2015, author:['Duncan Williams', 'Alexis Kirke', 'Eduardo R Miranda', 'Etienne Roesch', 'Ian Daly', 'Slawomir Nasuto']})
RETURN v $$) as (v agtype);
SELECT * FROM cypher('citation_graph', $$
CREATE (v:Article {id: 'williams2013towards', title: 'Towards affective algorithmic composition', publisher: 'University of Jyväskylä, Department of Music', year: 2013, author:['Duncan Williams', 'Alexis Kirke', 'Eduardo R Miranda', 'Etienne Roesch', 'Slawomir Nasuto']})
RETURN v $$) as (v agtype);
SELECT * FROM cypher('citation_graph', $$
CREATE (v:Article {id: 'schubert1999measurement', title: 'Measurement and Time Series Analysis of Emotion in Music', publisher: 'University of New South Wales. Music & Music Education', year: 1999, author:['Emery Schubert']})
RETURN v $$) as (v agtype);
SELECT * FROM cypher('citation_graph', $$
CREATE (v:Article {id: 'scherer2004which', title: 'Which Emotions Can be Induced by Music? What Are the Underlying Mechanisms? And How Can We Measure Them?', publisher: 'Journal of New Music Research', year: 2004, author:['Klaus R. Scherer']})
RETURN v $$) as (v agtype);
SELECT * FROM cypher('citation_graph', $$
CREATE (v:Article {id: 'gabrielsson2001emotion', title: 'Emotion perceived and emotion felt: Same or different?', publisher: 'Musicae Scientiae', year: 2001, author:['Alf Gabrielsson']})
RETURN v $$) as (v agtype);
SELECT * FROM cypher('citation_graph', $$
CREATE (v:Article {id: 'scherer2001emotional', title: 'Emotional effects of music: Production rules', publisher: 'Oxford University Press', year: 2001, author:['Klaus Scherer', 'Marcel Zentner']})
RETURN v $$) as (v agtype);
SELECT * FROM cypher('citation_graph', $$
CREATE (v:Article {id: 'juslin2001communicating', title: 'Communicating emotion in music performance: A review and a theoretical framework', publisher: 'Oxford University Press', year: 2001, author:['Patrik Juslin']})
RETURN v $$) as (v agtype);
SELECT * FROM cypher('citation_graph', $$
CREATE (v:Article {id: 'williams2015dynamic', title: 'Dynamic Game Soundtrack Generation in Response to a Continuously Varying Emotional Trajectory', publisher: 'Audio Engineering Society Conference: 56th International Conference: Audio for Games', year: 2015, author:['Duncan Williams', 'Alexis Kirke', 'Joel Eaton', 'Eduardo Miranda', 'Ian Daly', 'James Hallowell', 'Etienne Roesch', 'Faustina Hwang', 'Slawomir Nasuto']})
RETURN v $$) as (v agtype);
SELECT * FROM cypher('citation_graph', $$
CREATE (v:Article {id: 'williams2015investigating', title: 'Investigating Perceived Emotional Correlates of Rhythmic Density in Algorithmic Music Composition', publisher: 'Association for Computing Machinery', year: 2015, author:['Duncan Williams', 'Alexis Kirke', 'Joel Eaton', 'Eduardo Miranda', 'Ian Daly', 'James Hallowell', 'James Weaver', 'Asad Malik', 'Etienne Roesch', 'Faustina Hwang', 'Slawomir Nasuto']})
RETURN v $$) as (v agtype);
SELECT * FROM cypher('citation_graph', $$
CREATE (v:Article { id: 'daly2015towards', title: 'Towards human-computer music interaction: Evaluation of an affectively-driven music generator via galvanic skin response measures', publisher: '2015 7th Computer Science and Electronic Engineering Conference (CEEC)', year: 2015, author:['Duncan Williams', 'Alexis Kirke', 'Eduardo Miranda', 'Ian Daly', 'Faustina Hwang', 'Slawomir Nasuto', 'Asad Malik', 'James Weaver']})
RETURN v $$) as (v agtype);
SELECT * FROM cypher('citation_graph', $$
CREATE (v:Article { id: 'kirke2013artificial', title: 'Artificial affective listening towards a machine learning tool for sound-based emotion therapy and control', publisher: 'Proceedings of the Sound and Music Computing Conference', year: 2013, author:['Alexis Kirke', 'Eduardo Miranda', 'Slawomir Nasuto']})
RETURN v $$) as (v agtype);
SELECT * FROM cypher('citation_graph', $$
CREATE (v:Article { id: 'kirke2012learningto', title: 'Learning to Make Feelings: Expressive Performance as a part of a machine learning tool for sound-based emotion therapy and control', publisher: 'the 9th Intl Symp on Computer Music Modeling and Retrieval', year: 2012, author:['Alexis Kirke', 'Eduardo Miranda', 'Slawomir Nasuto']})
RETURN v $$) as (v agtype);
SELECT * FROM cypher('citation_graph', $$
CREATE (v:Article { id: 'lopez2010real', title: 'Real-Time Emotion-Driven Music Engine', publisher: 'the 9th Intl Symp on Computer Music Modeling and Retrieval', year: 2010, author:['Alex Lopez', 'Antonio Oliveira', 'Amilcar Cardoso']})
RETURN v $$) as (v agtype);
SELECT * FROM cypher('citation_graph', $$
CREATE (v:Article { id: 'oliveira2008affective', title: 'Affective-driven music production: selection and transformation of music', publisher: 'ARTECH', year: 2008, author:['Antonio Oliveira', 'Amilcar Cardoso']})
RETURN v $$) as (v agtype);
SELECT * FROM cypher('citation_graph', $$
CREATE (v:Article { id: 'oliveira2008modeling', title: 'Modeling affective content of music: A knowledge base approach', publisher: 'Sound and Music Computing Conference', year: 2008, author:['Antonio Oliveira', 'Amilcar Cardoso']})
RETURN v $$) as (v agtype);
SELECT * FROM cypher('citation_graph', $$
CREATE (v:Article { id: 'livingstone2007controlling', title: 'Controlling musical emotionality: an affective computational architecture for influencing musical emotions', publisher: 'Digital Creativity', year: 2007, author:['Steven R. Livingstone', 'Ralf Mühlberger', 'Andrew Brown', 'Andrew Loch']})
RETURN v $$) as (v agtype);
SELECT * FROM cypher('citation_graph', $$
CREATE (v:Article { id: 'livingstone2005dynamic', title: 'Dynamic Response: Real-Time Adaptation for Music Emotion', publisher: 'Creativity & Cognition Studios Press', year: 2005, author:['Steven R. Livingstone','Andrew Brown']})
RETURN v $$) as (v agtype);
SELECT * FROM cypher('citation_graph', $$
CREATE (v:Article { id: 'oliveira2009automatic', title: 'Automatic manipulation of music to express desired emotions', publisher: 'Proceedings of the 6th Sound and Music Computing Conference', year: 2009, author:['Antonio Oliveira', 'Amilcar Cardoso']})
RETURN v $$) as (v agtype);
SELECT * FROM cypher('citation_graph', $$
CREATE (v:Article { id: 'russell1980circumplex', title: 'A circumplex model of affect', publisher: 'American Psychological Association', year: 1980, author:['James Russel']})
RETURN v $$) as (v agtype);
# Create all edges
SELECT * FROM cypher ('citation_graph', $$
MATCH (a:Article), (b:Article)
WHERE a.id = 'williams2015affect' and b.id = 'williams2013towards'
CREATE (a)-[e:CITES]->(b)
RETURN e
$$) as (e agtype);
SELECT * FROM cypher ('citation_graph', $$
MATCH (a:Article), (b:Article)
WHERE a.id = 'williams2015affect' and b.id = 'kirke2012learningto'
CREATE (a)-[e:CITES]->(b)
RETURN e
$$) as (e agtype);
SELECT * FROM cypher ('citation_graph', $$
MATCH (a:Article), (b:Article)
WHERE a.id = 'williams2015affect' and b.id = 'oliveira2008affective'
CREATE (a)-[e:CITES]->(b)
RETURN e
$$) as (e agtype);
SELECT * FROM cypher ('citation_graph', $$
MATCH (a:Article), (b:Article)
WHERE a.id = 'williams2015affect' and b.id = 'livingstone2007controlling'
CREATE (a)-[e:CITES]->(b)
RETURN e
$$) as (e agtype);
SELECT * FROM cypher ('citation_graph', $$
MATCH (a:Article), (b:Article)
WHERE a.id = 'williams2015affect' and b.id = 'livingstone2005dynamic'
CREATE (a)-[e:CITES]->(b)
RETURN e
$$) as (e agtype);
SELECT * FROM cypher ('citation_graph', $$
MATCH (a:Article), (b:Article)
WHERE a.id = 'williams2015affect' and b.id = 'gabrielsson2001emotion'
CREATE (a)-[e:CITES]->(b)
RETURN e
$$) as (e agtype);
SELECT * FROM cypher ('citation_graph', $$
MATCH (a:Article), (b:Article)
WHERE a.id = 'williams2015affect' and b.id = 'schubert1999measurement'
CREATE (a)-[e:CITES]->(b)
RETURN e
$$) as (e agtype);
SELECT * FROM cypher ('citation_graph', $$
MATCH (a:Article), (b:Article)
WHERE a.id = 'williams2015affect' and b.id = 'russell1980circumplex'
CREATE (a)-[e:CITES]->(b)
RETURN e
$$) as (e agtype);
SELECT * FROM cypher ('citation_graph', $$
MATCH (a:Article), (b:Article)
WHERE a.id = 'daly2015towards' and b.id = 'williams2015affect'
CREATE (a)-[e:CITES]->(b)
RETURN e
$$) as (e agtype);
SELECT * FROM cypher ('citation_graph', $$
MATCH (a:Article), (b:Article)
WHERE a.id = 'daly2015towards' and b.id = 'williams2015dynamic'
CREATE (a)-[e:CITES]->(b)
RETURN e
$$) as (e agtype);
SELECT * FROM cypher ('citation_graph', $$
MATCH (a:Article), (b:Article)
WHERE a.id = 'daly2015towards' and b.id = 'gabrielsson2001emotion'
CREATE (a)-[e:CITES]->(b)
RETURN e
$$) as (e agtype);
SELECT * FROM cypher ('citation_graph', $$
MATCH (a:Article), (b:Article)
WHERE a.id = 'daly2015towards' and b.id = 'russell1980circumplex'
CREATE (a)-[e:CITES]->(b)
RETURN e
$$) as (e agtype);
SELECT * FROM cypher ('citation_graph', $$
MATCH (a:Article), (b:Article)
WHERE a.id = 'williams2015dynamic' and b.id = 'williams2015investigating'
CREATE (a)-[e:CITES]->(b)
RETURN e
$$) as (e agtype);
SELECT * FROM cypher ('citation_graph', $$
MATCH (a:Article), (b:Article)
WHERE a.id = 'williams2015dynamic' and b.id = 'williams2015affect'
CREATE (a)-[e:CITES]->(b)
RETURN e
$$) as (e agtype);
SELECT * FROM cypher ('citation_graph', $$
MATCH (a:Article), (b:Article)
WHERE a.id = 'williams2015dynamic' and b.id = 'russell1980circumplex'
CREATE (a)-[e:CITES]->(b)
RETURN e
$$) as (e agtype);
SELECT * FROM cypher ('citation_graph', $$
MATCH (a:Article), (b:Article)
WHERE a.id = 'williams2015investigating' and b.id = 'williams2013towards'
CREATE (a)-[e:CITES]->(b)
RETURN e
$$) as (e agtype);
SELECT * FROM cypher ('citation_graph', $$
MATCH (a:Article), (b:Article)
WHERE a.id = 'williams2015investigating' and b.id = 'kirke2013artificial'
CREATE (a)-[e:CITES]->(b)
RETURN e
$$) as (e agtype);
SELECT * FROM cypher ('citation_graph', $$
MATCH (a:Article), (b:Article)
WHERE a.id = 'kirke2012learningto' and b.id = 'oliveira2009automatic'
CREATE (a)-[e:CITES]->(b)
RETURN e
$$) as (e agtype);
SELECT * FROM cypher ('citation_graph', $$
MATCH (a:Article), (b:Article)
WHERE a.id = 'lopez2010real' and b.id = 'oliveira2008modeling'
CREATE (a)-[e:CITES]->(b)
RETURN e
$$) as (e agtype);
SELECT * FROM cypher ('citation_graph', $$
MATCH (a:Article), (b:Article)
WHERE a.id = 'lopez2010real' and b.id = 'livingstone2007controlling'
CREATE (a)-[e:CITES]->(b)
RETURN e
$$) as (e agtype);
SELECT * FROM cypher ('citation_graph', $$
MATCH (a:Article), (b:Article)
WHERE a.id = 'lopez2010real' and b.id = 'scherer2001emotional'
CREATE (a)-[e:CITES]->(b)
RETURN e
$$) as (e agtype);
SELECT * FROM cypher ('citation_graph', $$
MATCH (a:Article), (b:Article)
WHERE a.id = 'lopez2010real' and b.id = 'schubert1999measurement'
CREATE (a)-[e:CITES]->(b)
RETURN e
$$) as (e agtype);
SELECT * FROM cypher ('citation_graph', $$
MATCH (a:Article), (b:Article)
WHERE a.id = 'oliveira2009automatic' and b.id = 'oliveira2008modeling'
CREATE (a)-[e:CITES]->(b)
RETURN e
$$) as (e agtype);
SELECT * FROM cypher ('citation_graph', $$
MATCH (a:Article), (b:Article)
WHERE a.id = 'oliveira2009automatic' and b.id = 'livingstone2005dynamic'
CREATE (a)-[e:CITES]->(b)
RETURN e
$$) as (e agtype);
SELECT * FROM cypher ('citation_graph', $$
MATCH (a:Article), (b:Article)
WHERE a.id = 'oliveira2009automatic' and b.id = 'juslin2001communicating'
CREATE (a)-[e:CITES]->(b)
RETURN e
$$) as (e agtype);
SELECT * FROM cypher ('citation_graph', $$
MATCH (a:Article), (b:Article)
WHERE a.id = 'oliveira2009automatic' and b.id = 'scherer2001emotional'
CREATE (a)-[e:CITES]->(b)
RETURN e
$$) as (e agtype);
SELECT * FROM cypher ('citation_graph', $$
MATCH (a:Article), (b:Article)
WHERE a.id = 'oliveira2009automatic' and b.id = 'schubert1999measurement'
CREATE (a)-[e:CITES]->(b)
RETURN e
$$) as (e agtype);
SELECT * FROM cypher ('citation_graph', $$
MATCH (a:Article), (b:Article)
WHERE a.id = 'oliveira2008affective' and b.id = 'oliveira2008modeling'
CREATE (a)-[e:CITES]->(b)
RETURN e
$$) as (e agtype);
SELECT * FROM cypher ('citation_graph', $$
MATCH (a:Article), (b:Article)
WHERE a.id = 'oliveira2008affective' and b.id = 'livingstone2005dynamic'
CREATE (a)-[e:CITES]->(b)
RETURN e
$$) as (e agtype);
SELECT * FROM cypher ('citation_graph', $$
MATCH (a:Article), (b:Article)
WHERE a.id = 'oliveira2008affective' and b.id = 'schubert1999measurement'
CREATE (a)-[e:CITES]->(b)
RETURN e
$$) as (e agtype);
SELECT * FROM cypher ('citation_graph', $$
MATCH (a:Article), (b:Article)
WHERE a.id = 'oliveira2008modeling' and b.id = 'livingstone2005dynamic'
CREATE (a)-[e:CITES]->(b)
RETURN e
$$) as (e agtype);
SELECT * FROM cypher ('citation_graph', $$
MATCH (a:Article), (b:Article)
WHERE a.id = 'oliveira2008modeling' and b.id = 'schubert1999measurement'
CREATE (a)-[e:CITES]->(b)
RETURN e
$$) as (e agtype);
SELECT * FROM cypher ('citation_graph', $$
MATCH (a:Article), (b:Article)
WHERE a.id = 'livingstone2007controlling' and b.id = 'livingstone2005dynamic'
CREATE (a)-[e:CITES]->(b)
RETURN e
$$) as (e agtype);
SELECT * FROM cypher ('citation_graph', $$
MATCH (a:Article), (b:Article)
WHERE a.id = 'livingstone2007controlling' and b.id = 'scherer2004which'
CREATE (a)-[e:CITES]->(b)
RETURN e
$$) as (e agtype);
SELECT * FROM cypher ('citation_graph', $$
MATCH (a:Article), (b:Article)
WHERE a.id = 'livingstone2007controlling' and b.id = 'juslin2001communicating'
CREATE (a)-[e:CITES]->(b)
RETURN e
$$) as (e agtype);
SELECT * FROM cypher ('citation_graph', $$
MATCH (a:Article), (b:Article)
WHERE a.id = 'livingstone2005dynamic' and b.id = 'juslin2001communicating'
CREATE (a)-[e:CITES]->(b)
RETURN e
$$) as (e agtype);
# Show all vertices and edges
SELECT * FROM cypher('citation_graph', $$
MATCH (a)
OPTIONAL MATCH (a)-[e]->(b)
RETURN a, e, b
$$) as (a agtype, e agtype, b agtype);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment