GraphAware Blog - Intermediate

Do you use D3 for data visualisation and are you now considering its usage for graph visualisation? Keep in mind that D3 uses SVG for rendering. While it is the easiest to work with API for drawing 2D graphics on the Web, its downside is that the browser keeps the entire DOM tree of vector elements in memory, even for elements that are effectively invisible. You might hit a performance drop with complex graphics, specifically for graph visualisation when you try drawing graphs larger than ~1000 nodes, or even less with complex SVG effects.At this time you should reconsider why...

The Cypher query planner is quite advanced and mature, and you can mostly rely on it to pick the best plan for your query. However, there are rare cases, or bugs, that might want you looking for ways to influence that plan. This article demonstrates practical usage of an index hint. Note that all queries were tested against Neo4j Enterprise 3.5.8The graph modelThis is the relevant portion of the graph model that is sufficient to demonstrate the issue.Simple enough- we have many tweets, and tweets have keywords.Our graph has two indexes, one on the value of the Keyword, and the...

As of version 2.1, Neo4j OGM will support persistence events. Although a date for the release of 2.1 isn’t known at thetime of writing, we think this is an important and exciting new feature and so we’ll be writing a series of posts aboutit over the next few weeks to whet your appetites. In this first post we’ll take a quick tour of the new Events mechanismin the OGM, and provide some examples of how we might use it in our own applications. But first, some background…OGM persistence strategyBy design, the OGM has a deep persistence strategy. This means that...

For most organisations, data security is extremely important. The topic comes up every single time we are training, consulting,or otherwise engaging in the world of graphs and Neo4j. At the same time, security is very difficult and time-consuming to get rightand the implications of getting it wrong can be serious. In this blog post, we introduce the integration of Spring Securityinto Neo4j which provides important security controls and mechanisms for enterprises and governments that make use of theworld’s most popular graph database.Security in Neo4jNeo4j comes with certain security mechanisms out of the box. These include HTTPS support,single-user authentication with all-or-nothing...

At GraphAware, we help organisations in a wide range of verticals solve problems with graphs.Once we come across a requirement or use case two or three different times, we typically create an open-source Neo4j extensionthat addresses it. The latest addition to our product portfolio, introduced in this post, is a simple library that automaticallyexpires data from the Neo4j graph database.GraphAware FrameworkOpen-sourcing useful extensions helps us deliver solutions faster, lets people who prefer a DIY approach be more productive, andgives us valuable community feedback. That’s how our most popular products, such as the GraphAware Recommendation Engine,TimeTree, UUID, and others were born.They...

Last month, I had the pleasure of speaking at GraphConnect in San Francisco, introducing the Graph-Aided Search to alarge audience of Neo4j users and graph enthusiasts. For those who missed the conference, the recording and slides havenow been made available. Enjoy and get in touch with feedback / questions!VideoSlides Real-Time Recommendations and the Future of Search from GraphAware

Last weekend, I came across a tweet announcing that Wikimedia released the dataset of the page clickstreamsfor February 2015. I found it interesting to download this dataset and see how people arrive on the Neo4j’s Wikipedia page.The data is quite simple; we have page entities that relate to other pages. A page can either be a Wikipedia page, ora non-Wikipedia page such as Google. Relationships can represent a user click from a Wikipedia page to another page, or a user searching on Google or Wikipedia. The number of times an event occurs is also provided in the dataset.Importing the DatasetYou...

Our earlier blog posttalked about using the Neo4j web browser along with embedded Neo4j.The WrappingNeoServerBootstrapper which was employed to do this has been deprecated for a while and it raises questionsabout the alternative.Testing server extensions is now possible(see Testing your extension)but there is still another use case for wanting to connect to an embedded graph - troubleshooting.Perhaps you have a web application running in production with Neo4j in embedded mode and you’ve got to troubleshoot an issue which requires access to the graph - how do you do this against a live graph?Well, there is another option which won’t give...

A common question when planning and designing your Neo4j Graph Database is how to handle “flagged” entities. This couldinclude users that are active, blog posts that are published, news articles that have been read, etc.IntroductionIn the SQL world, you would typically create a a boolean|tinyint column; in Neo4j, the same can be achieved in thefollowing two ways: A flagged indexed property A dedicated labelHaving faced this design dilemma a number of times, we would like to share our experience with the twopresented possibilities and some Cypher query optimizations that will help you take a full advantage of a the graph...

There are times when you have an application using Neo4j in embedded mode but also need to play around with the graphusing the Neo4j web browser. Since the database can be accessed from at most one process at a time, trying to start upthe Neo4j server when your embedded Neo4j application is running won’t work. The WrappingNeoServerBootstrapper,although deprecated, comes to the rescue. Here’s how to set it up.Maven Dependencies<dependency> <groupId>org.neo4j</groupId> <artifactId>neo4j</artifactId> <version>2.1.5</version></dependency><dependency> <groupId>org.neo4j.app</groupId> <artifactId>neo4j-server</artifactId> <version>2.1.5</version></dependency><dependency> <groupId>org.neo4j.app</groupId> <artifactId>neo4j-server</artifactId> <version>2.1.5</version> <classifier>static-web</classifier></dependency>Start the WrappingNeoServerBootstrapperpublic static void connectAndStartBootstrapper() { WrappingNeoServerBootstrapper neoServerBootstrapper; GraphDatabaseService db = new GraphDatabaseFactory() .newEmbeddedDatabaseBuilder("/path/to/db").newGraphDatabase(); try { GraphDatabaseAPI api = (GraphDatabaseAPI) db;...

Last month, I had the pleasure of speaking at GraphConnect in San Francisco, introducing the GraphAware Framework to alarge audience of Neo4j users and graph enthusiasts. For those who missed the conference, the recording and slides havenow been made available. Enjoy and get in touch with feedback / questions!VideoSlides GraphAware Framework Intro from Michal Bachman

Modelling and querying time-based events in a graph is a fairly common discussion topic and a frequently asked questionon Q/A sites. In this blog post, we evaluate some of the common approaches and introduce GraphAware TimeTree, a GraphAware Framework Module that simplifies modelling time and events in Neo4j.Naive ApproachNeo4j has no notion of a Date/Time data type, so you have to decide to store the timestamp either as a long, or asa human-readable String, for instance formatted as ‘YYYY-MM-DD HH:mm:ss’. Unless the time is only for human eyes, though,we recommend opting for the machine readable (long) approach. It is simply...

In the first part of this short series aboutrandom graph models, we talked about why they are useful and had a brief look at two of them: Erdos-Renyi graphs andBarabasi-Albert model. In this post, we take a look at the “small world” phenomenon and another network model, namelythe Watts-Strogatz model.Small WorldThere is an important property of random networks which we did not write about in the last blog post: the way thenode separation scales with network size. Both Erdos-Renyi and Barabasi-Albert networks are “small world” models, meaningthat the characteristic node separation scales logarithmically with number of nodes present in the...

When one obtains a graph data from a measurement on a real world network, it is sometimes useful to make comparison witha random graph. Such graph is characterised by certain degree distribution, which you can imagine to be a list of degreesof nodes present in the network. The most interesting distributions have certain functional dependence which allowsone to infer what processes are dominant in formation of the network. The processes consequently characterise therelationships between the nodes.Why would one care about such analysis?Imagine a group of customers that you want to target efficiently in a certain fashion. Say, for instance, that...

A couple of days ago, I wrote about unit testing with GraphUnit.GraphUnit tested the state of an embedded Neo4j database. What if you run Neo4j in standalone server mode?Fortunately, you can still test it and match subgraphs using the GraphAware Neo4j RestTest library.SetupGrab the GraphAware Neo4j Framework and GraphAware Neo4j RestTest jars from the Downloads page. Drop them into the plugins directory of your Neo4j installation and restart the server to be able to use the API’s.How to use itAll you have to do is POST your cypher to http://your-server-address:7474/graphaware/resttest/assertSameGraph orhttp://your-server-address:7474/graphaware/resttest/assertSubgraph to verify the state of your graph.Emptying the database...

Testing the state of an Embedded Neo4j database is now much easier if you use GraphUnit, a component of the GraphAware Neo4j Framework.I tried replacing an existing Flavorwocky unit test with GraphUnit to check out the benefits.Let’s walk through a before-after case study.The testThe unit test in question is the one to test that a Pairing is saved correctly. A pairing must have exactly two ingredients. Each Ingredient node has a name; a Pairing has an affinity and an array of allAffinities (all affinities ever assigned to the pairing).BeforePseudocode to test that my code saved a pairing correctly in Neo4j:...

Recently, we announced the GraphAware Framework. Today, I would like to introduce its first feature called GraphUnit. GraphUnit is a component that helps Java developers unit test their code that talks to Neo4j and mutates data.Unit Testing Neo4j CodeWhen writing Java code that modifies data stored in Neo4j, developers can use the ImpermanentGraphDatabase in conjunction with any of APIs provided by Neo4jto test that code. This includes the native Java API, the traversal framework, and Cypher.(I’ve excluded the REST API because using that to unit test Java code wouldn’t make much sense.)Let’s say we’re testing code that creates two nodes...

In this short blog post, I would like to introduce the GraphAware Neo4j Framework.Its goal is very ambitious: we’d like to make it as useful for Neo4j developers, as the Spring Framework is for Java developers. The Framework aims at speeding up development with Neo4j by providing a platform for building useful generic aswell as domain-specific functionality, analytical capabilities, graph algorithms, and more.Features OverviewOn a high level, there are two key pieces of functionality, GraphAware Server and GraphAware Runtime. GraphAwareServer is a Neo4j server extension that allows developers to build (REST) APIs on top of Neo4j using Spring MVC, ratherthan...