Skip to content

Directed graph representation

dkoszewnik edited this page Mar 8, 2013 · 1 revision

All data can be represented in the form of a directed graph. Some data lends itself very well to this representation. In these cases, NetflixGraph can help you reduce your application’s memory footprint, or reduce the latency which your data can be accessed by holding it in RAM.

The following examples are alternate in-memory representations of the data in the examples on the Usage page. In both cases, using NetflixGraph would provide a greatly improved memory profile:

Object References

Objects which refer to other objects are naturally representing graph data. For example, the objects below are another way of representing the data in the examples on the Usage page:

class Movie {
	String name;
	Rating rating;
	List<Actor> actors;
}

class Actor {
	String name;
	Set<Actor> costarredWith;
	List<Movie> starredIn;
}

class Rating {
	String rating;
}

Maps

A Map between two objects is easily represented with graph data. The following Maps are alternate representations of the same Movie relationships above, and can therefore also be represented with the examples on the Usage page:

Map<Movie, Rating> movieRatingMap
Map<Movie, List<Actor>> actors
Clone this wiki locally