Start United States USA — software Weighted Graph Queries in InfiniteGraph

Weighted Graph Queries in InfiniteGraph

237
0
TEILEN

In this article, learn the concept of a weighted graph and queries in the InfiniteGraph database and show how InfiniteGraph offers several unique advantages.
Join the DZone community and get the full member experience. Graph databases have moved to the forefront of trendy technologies. There are a lot of mature companies with graph database technologies and a lot of new players seem to be arriving on the scene almost daily and for good reason; graphs are a more natural way to represent data. They excel at modeling and managing the connections between data elements and this opens up new possibilities for what we can accomplish with our data. In this blog, we will introduce the concept of a weighted graph and weighted graph queries in the InfiniteGraph database and show how InfiniteGraph offers several unique advantages for performing weighted graph queries. A graph is made up of nodes, sometimes called vertices, and edges. The nodes of a graph typically represent a person, place, or thing and are drawn using a circle. Edges represent relationships between nodes and are drawn as a line between the two nodes. Figure 1: A Graph InfiniteGraph is a massively scalable, distributable, graph database. InfiniteGraph is a schema-based graph database. InfiniteGraph has its own query language called “DO”. Consider the graph shown in Figure 2. Figure 2: A Simple Graph In this graph, all we have are nodes with labels and edges that connect the nodes. If this graph represented people and their social connections to other people, you could figure out how two people are connected. You could figure out that A and C are a separated by minimum of two degrees, and this graph is perfectly fine for this kind of question. However, if this graph represented towns and the roads that connect them, this graph can be used to find routes between towns, but it doesn’t provide enough information to find the best route since it doesn’t provide information on how far apart the towns are. This graph is insufficient for finding the shortest route from one town to another. For this, and many other kinds of problems, we need weighted graphs. A weighted graph is a graph where a weight value is associated with each edge. The weight values, called edge-weights, typically serves as some kind of cost factor that is incurred when traversing the edge. In our map example above, the cost factor might be the distance associated with each road represented by the edge. Consider the following graph in Figure 3: Figure 3: A Weighted Graph Here, the edge weight on the edge from A to B represents the distance from A to B and has a value of 4. By summing the edge weights for a particular route, we will know the total distance for that route. To go from A to B to C, we add 4 + 5 and get a total distance of 9. We can compare the total distances for the different routes between a given starting point and endpoint to determine which route is the shortest. In many cases, the edge-weight will simply be the value of an attribute on the edge data item. In our case, we would have a Road data item with a distance attribute.

Continue reading...