Bipartite Graph
A bipartite graph (also called a two-mode graph) is a type of graph where vertices are separated into two disjoint sets. These sets are usually called top and bottom vertices. An edge in this graph can only connect vertices from opposite sets (i.e. bottom vertex to top vertex) and cannot connect two vertices in the same set.
These graphs have wide application in practice and can be a more natural choice for particular domains. For example to represent authorship of scientific papers top vertices can represent scientific papers while bottom nodes will represent authors. Naturally an edge between a top and a bottom nodes would represent an authorship of a particular scientific paper. Another common example for applications of bipartite graphs is relationships between actors and movies. In this case an edge represents that a particular actor played in a movie.
Bipartite graphs are used instead of regular graphs (one-mode) for the following practical reasons:
- Bipartite graphs can encode the same information more compactly than one-mode graphs
A is represented by:
- A
DataSet
of top nodes - A
DataSet
of bottom nodes - A
DataSet
of edges between top and bottom nodes
As in the Graph
class nodes are represented by the Vertex
type and the same rules apply to its types and values.
The graph edges are represented by the BipartiteEdge
type. A is defined by a top ID (the ID of the top Vertex
), a bottom ID (the ID of the bottom Vertex
) and an optional value. The main difference between the Edge
and BipartiteEdge
is that IDs of nodes it links can be of different types. Edges with no value have a NullValue
value type.
Scala
You can create a in the following ways:
from a
DataSet
of top vertices, aDataSet
of bottom vertices and aDataSet
of edges:Java
Scala
// Scala API is not yet supported
- Projection: Projection is a common operation for bipartite graphs that converts a bipartite graph into a regular graph. There are two types of projections: top and bottom projections. Top projection preserves only top nodes in the result graph and creates a link between them in a new graph only if there is an intermediate bottom node both top nodes connect to in the original graph. Bottom projection is the opposite to top projection, i.e. only preserves bottom nodes and connects a pair of nodes if they are connected in the original graph.
In the case of a simple projection each node in the result graph contains a pair of values of bipartite edges that connect nodes in the original graph:
Java
Scala
// Scala API is not yet supported
Full projection preserves all the information about the connection between two vertices and stores it in Projection
instances. This includes value and id of an intermediate vertex, source and target vertex values and source and target edge values:
Java
Scala