On Graph Computing
Join the DZone community and get the full member experience.Join For Free
the concept of a graph has been around since the dawn of mechanical computing and for many decades prior in the domain of pure mathematics. due in large part to this golden age of databases, graphs are becoming increasingly popular in software engineering. graph databases provide a way to persist and process graph data. however, the graph database is not the only way in which graphs can be stored and analyzed. graph computing has a history prior to the use of graph databases and has a future that is not necessarily entangled with typical database concerns. there are numerous graph technologies that each have their respective benefits and drawbacks. leveraging the right technology at the right time is required for effective graph computing.
structure: modeling real-world scenarios with graphs
a graph (or network ) is a data structure. it is composed of vertices (dots) and edges (lines). many real-world scenarios can be modeled as a graph. this is not necessarily inherent to some objective nature of reality, but primarily predicated on the the fact that humans subjectively interpret the world in terms of objects (vertices) and their respective relationships to one another (edges) (an argument against this idea). the popular data model used in graph computing is the property graph . the following examples demonstrate graph modeling via three different scenarios.
a software graph
stephen is a member of a graph-oriented engineering group called tinkerpop . stephen contributes to rexster . rexster is related to other projects via software dependencies. when a user finds a bug in rexster, they issue a ticket . this description of a collaborative coding environment can be conveniently captured by a graph. the vertices (or things) are people, organizations, projects, and tickets. the edges (or relationships) are, for example, memberships, dependencies, and issues. a graph can be visualized using dots and lines and the scenario described above is diagrammed below.
a discussion graph
matthias is interested in graphs. he is the cto of aurelius and the project lead for the graph database titan . aurelius has a mailing list . on this mailing list, people discuss graph theory and technology. matthias contributes to a discussion. his contributions beget more contributions. in a recursive manner, the mailing list manifests itself as a tree . moreover, the unstructured text of the messages make reference to shared concepts.
a concept graph
a graph can be used to denote the relationships between arbitrary concepts, even the concepts related to graph . for example, note how concepts (in italics) are related in the sentences to follow. a graph can be represented as an adjacency list . the general way in which graphs are processed are via graph traversals . there are two general types of graph traversals : depth-first and breadth-first . graphs can be persisted in a software system known as a graph database . graph databases organize information in a manner different from the relational databases of common software knowledge. in the diagram below, the concepts related to graph are linked to one another demonstrating that concept relationships form a graph.
a multi-domain graph
the three previous scenarios (software, discussion, and concept) are representations of real-world systems (e.g. github , google groups , and wikipedia ). these seemingly disparate models can be seamlessly integrated into a single atomic graph structure by means of shared vertices. for instance, in the associated diagram, gremlin is a titan dependency, titan is developed by matthias, and matthias writes messages on aurelius’ mailing list (software merges with discussion). next, blueprints is a titan dependency and titan is tagged graph (software merges with concept). the dotted lines identify other such cross-domain linkages that demonstrate how a universal model is created when vertices are shared across domains. the integrated, universal model can be subjected to processes that provide richer (perhaps, more intelligent) services than what any individual model could provide alone.
process: solving real-world problems with traversals
what has been presented thus far is a single graph model of a set of interrelated domains. a model is only useful if there are processes that can leverage it to solve problems. much like data needs algorithms, a graph needs a traversal . a traversal is an algorithmic/directed walk over the graph such that paths are determined (called derivations) or information is gleaned (called statistics). even the human visual system viewing a graph visualization is a traversal engine leveraging saccadic movements to identify patterns. however, as graphs grow large and problems demand precise logic, visualizations and the human’s internal calculator break down. a collection of traversal examples are presented next that solve typical problems in the previously discussed domains.
determining circular dependencies
with the growth of open source software and the ease by which modules can be incorporated into projects, circular dependencies abound and can lead to problems in software engineering. a circular dependency occurs when project a depends on project b and, through some dependency path, project b depends on project a . when dependencies are represented graphically, a traversal can easily identify such circularities (e.g. in the diagram below, a->b->d->g->a is a cycle ).
ranking discussion contributors
mailing lists are composed of individuals with varying levels of participation and competence. when a mailing list is focused on learning through discussion, simply writing a message is not necessarily a sign of positive contribution. if an author’s messages spawn replies, then it can be interpreted that the author is contributing discussion-worthy material. however, if an author’s messages end the conversation, then they may be contributing non-sequiturs or information that is not allowing the discussion to flourish. in the associated diagram, the beige vertices are authors and their respective number is a unique author id.
one way to rank contributors on a mailing list is to count the number of messages they have posted (the author’s out-degree to messages in the mailing list). however, if the ranking must account for fruitful contributions, then authors can be ranked by the depth of the discussion their messages spawn (the tree depth of the author’s messages). finally, note that other techniques such as sentiment and concept analysis can be included in order to understand the itention and meaning of a message.
finding related concepts
stephen’s understanding of graphs was developed while working on tinkerpop’s graph technology stack. nowadays he is interested in learning more about the theoretical aspects of graphs. via his web browser, he visits the graph wikipedia page. in a manual fashion, stephen clicks links and reads articles — depth-first, graph traversals, adjacency lists, etc. he realizes that pages reference each other and that some concepts are more related to others due to wikipedia’s link structure. the manual process of walking links can be automated using a graph traversal. instead of clicking, a traversal can start at the graph vertex, emanate outwards, and report which concepts have been touched the most. the concept that has seen the most flow , is a concept that has many ties (i.e. paths) to graph (see priors algorithms ). with such a traversal, stephen can be provided a ranked list of graph related concepts. this traversal is analogous to a wave diffusing over a body of water — albeit real-world graph topologies are rarely as simple as a two-dimensional plane (see lattice ).
a multi-domain traversal
the different graph models discussed previously (i.e. software, discussion, and concept) were integrated into a single world model via shared vertices. analogously, the aforementioned graph traversals can be composed to yield a solution to a cross-domain problem. for example:
“recommend me projects to participate in that maintain a proper dependency structure, have engaging contributors promoting the space, and are conceptually related to technologies i’ve worked on previously.”
this type of problem solving is possible when a heterogenous network of things is linked together and effectively moved within. the means of linking and moving is the graph and the traversal, respectively. to conclude this section, other useful traversal examples are provided.
“compute a ‘stability rank’ for a project based on the number of issues it has and the number of issues its dependencies have, so forth and so on in a recursive manner.”
“cluster projects according to shared (or similar) concepts between them.”
“recommend a team of developers for an upcoming project that will use x dependencies and is related to y concepts.”
“rank issues by the number of projects that each issue’s submitter has contributed to.”
graph computing technologies
the practice of computing is about riding the fine line between two entangled quantities: space and time. in the world of graph computing, the same tradeoffs exist. this section will discuss various graph technologies in order to identify what is gained and sacrificed with each choice. moreover, a few example technologies are presented. note that many more technologies exist and the mentioned examples are by no means exhaustive.
in-memory graph toolkits
in-memory graph toolkits are single-user systems that are oriented towards graph analysis and visualization. they usually provide implementations of the numerous graph algorithms defined in the graph theory and network science literature (see wikipedia’s list of graph algorithms ). the limiting factor of these tools is that they can only operate on graphs that can be stored in local, main memory. while this can be large (millions of edges), it is not always sufficient. if the source graph data set is too large to fit into main memory, then subsets are typically isolated and processed using such in-memory graph toolkits.
- [+] rich graph algorithm libraries
- [+] rich graph visualization libraries
- [+] different memory representations for different space/time tradeoffs
- [-] constrained to graphs that can fit into main memory
- [-] interaction is normally very code heavy
real-time graph databases
graph databases are perhaps the most popular incarnation of a graph computing technology. they provide transactional semantics such as acid (typical of local databases) and eventual consistency (typical of distributed databases). unlike in-memory graph toolkits, graph databases make use of the disk to persist the graph. on reasonable machines, local graph databases can support a couple billion edges while distributed systems can handle hundreds of billions of edges. at this scale and with multi-user concurrency, where random access to disk and memory are at play, global graph algorithms are not feasible. what is feasible is local graph algorithms/traversals. instead of traversing the entire graph, some set of vertices serve as the source (or root) of the traversal.
- [+] optimized for local neighborhood analyses (“ego-centric” traversals)
- [+] optimized for handling numerous concurrent users
- [+] interactions are via graph-oriented query/traversal languages
- [-] global graph analytics are inefficient due to random disk interactions
- [-] large computational overhead due to database functionality (e.g. transactional semantics)
batch processing graph frameworks
batch processing graph frameworks make use of a compute cluster. most of the popular frameworks in this space leverage hadoop for storage (hdfs) and processing (mapreduce). these systems are oriented towards global analytics. that is, computations that touch the entire graph dataset and, in many instances, touch the entire graph many times over (iterative algorithms). such analyses do not run in real-time. however, because they perform global scans of the data, they can leverage sequential reads from disk (see the pathology of big data ). finally, like the in-memory systems, they are oriented towards the data scientist or, in a production setting, for feeding results back into a real-time graph database.
- [+] optimized for global graph analytics
- [+] process graphs represented across a machine cluster
- [+] leverages sequential access to disk for fast read times
- [-] does not support multiple concurrent users
- [-] are not real-time graph computing systems
this section presented different graph computing solutions. it is important to note that there also exists hardware solutions like convey’s mx series and cray’s yarc graph engines. each of the technologies discussed all share one important theme — they are focused on processing graph data. the tradeoffs of each category are determined by the limits set forth by modern hardware/software and, ultimately, theoretical computer science.
to the adept, graph computing is not only a set of technologies, but a way of thinking about the world in terms of graphs and the processes therein in terms of traversals. as data is becoming more accessible, it is easier to build richer models of the environment. what is becoming more difficult is storing that data in a form that can be conveniently and efficiently processed by different computing systems. there are many situations in which graphs are a natural foundation for modeling. when a model is a graph, then the numerous graph computing technologies can be applied to it.
mike loukides of o’reilly was kind enough to review multiple versions of this article and in doing so, made the article all the better.
Published at DZone with permission of Marko Rodriguez, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.