Instagram Landscapes: Building Network Graphs with Neo4J in Python

modeling connected communities

Nodes of Creation

from py2neo import Database, Graph, Node, Relationship
db = py2neo.Database() # instantiate using default bolt port
g = py2neo.Graph(host='localhost', auth = ('neo4j','password'))
tx = g.begin()  # create new transactionkevin = Node('Crab', name = 'Kevin')
tx.create(kevin) # create node: label/type = Crab, name = Kevin
margot = Node('Jellyfish', name = 'Margot', color = 'purple')
margot['color'] = 'green' # update property, dictionary style
tx.create(margot)
rel = Relationship(kevin, 'FRIENDS_WITH', margot)
tx.create(rel) # create friendship between marine life
tx.commit() # push changes to connected graph, close transaction

Filling Out Your Graph

much more readable with color

Feature Engineering

I don’t understand this, but my graph might

Next steps in graphing

tell me that doesn’t look like jellyfish.

data scientist, machine learning engineer. passionate about ecology, biotech and AI. https://www.linkedin.com/in/mark-s-cleverley/

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store