BipartiteIndexedGraph

A graph is bipartite if the set of vertices can be partitioned into two blocks such that there is no edge between vertices of different blocks. Here we adopt the notation of referring to these as the "left" and "right" block.

A BipartiteIndexedGraph behaves just like a bipartite, undirected IndexedGraph, with two differences:

  • Vertices can be indexed as usual via their integer index (which is called here a linearindex), or via a BipartiteGraphVertex, i.e. by specifying Left or Right and the integer index of that vertex within its block. The typical use case is that where one has two vectors storing vertex properties of the two blocks, possibly with different eltypes, and each with indices starting at one.
  • The adjacency matrix of a bipartite graph (possibly after permutation of the vertex indices) is made of two specular rectangular submatrices A. Only one of these is stored, leading to a slight improvement in efficiency.

BipartiteIndexedGraphs use the same edge type IndexedEdge as the other AbstractIndexedGraphs, which stores source and destination as linear indices. To retrieve the in-block indices of the two vertices incident on an edge, use vertex_left, vertex_right.

IndexedGraphs.BipartiteIndexedGraphType
BipartiteIndexedGraph{T<:Integer} <: AbstractIndexedGraph{T}

A type representing a sparse, undirected bipartite graph.

FIELDS

  • A – adjacency matrix filled with NullNumbers. Rows are vertices belonging to the left block, columns to the right block
  • X – square matrix for efficient access by row. X[j,i] points to the index of element A[i,j] in A.nzval.
source
IndexedGraphs.BipartiteIndexedGraphMethod
BipartiteIndexedGraph(A::AbstractMatrix)

Construct a BipartiteIndexedGraph from adjacency matrix A with the convention that rows are vertices belonging to the left block, columns to the right block

source
IndexedGraphs.BipartiteGraphVertexType
BipartiteGraphVertex

A BipartiteGraphVertex{LR<:LeftorRight,T<:Integer} represents a vertex in a bipartite graph.

PARAMETERS

FIELDS

  • i – The index of the vertex within its block.
source
IndexedGraphs.linearindexFunction
linearindex(g::BipartiteIndexedGraph, v::BipartiteGraphVertex{LR}) where {LR<:LeftorRight}
linearindex(g::BipartiteIndexedGraph, i::Integer, ::Type{LR}) where LR<:LeftorRight

Return the linear index of a vertex, specified either by a BipartiteGraphVertex or by its index and block.

source
IndexedGraphs.vertex_leftFunction
vertex_left(g::BipartiteIndexedGraph, e::IndexedEdge)

Return the (in-block) index of the left-block vertex in e.

source
IndexedGraphs.inedgesMethod
inedges(g::BipartiteIndexedGraph, i::Integer)

Return a lazy iterator to the edges incident on a variable i specified by its linear index, with i as the destination.

source
IndexedGraphs.inedgesMethod
inedges(g::BipartiteIndexedGraph, v::BipartiteGraphVertex{<:LeftorRight})

Return a lazy iterator to the edges incident on a variable v specified by a BipartiteGraphVertex, with v as the destination.

source
IndexedGraphs.outedgesMethod
outedges(g::BipartiteIndexedGraph, i::Integer)

Return a lazy iterator to the edges incident on a variable i specified by its linear index, with i as the source.

source

Overrides from Graphs.jl

Graphs.inneighborsMethod
inneighbors(g::BipartiteIndexedGraph, i::Integer)

Return a lazy iterator to the neighbors of variable i specified by its linear index.

source
Graphs.outneighborsMethod
outneighbors(g::BipartiteIndexedGraph, i::Integer)

Return a lazy iterator to the neighbors of variable i specified by its linear index.

source
Graphs.LinAlg.adjacency_matrixFunction
adjacency_matrix(g::BipartiteIndexedGraph, T::DataType=Int)

Return the symmetric adjacency matrix of size nv(g) = nv_left(g) + nv_right(g) where no distinction is made between left and right nodes.

source

Generators

IndexedGraphs.rand_bipartite_graphMethod
rand_bipartite_graph([rng=default_rng()], nleft, nright, ned)

Create a bipartite graph with nleft nodes in the left block, nright nodes in the right block and ned edges taken uniformly at random.

source
IndexedGraphs.rand_bipartite_graphMethod
rand_bipartite_graph([rng=default_rng()], nleft, nright, p)

Create a bipartite graph with nleft nodes in the left block, nright nodes in the right block and edges taken independently with probability p.

source
IndexedGraphs.rand_regular_bipartite_graphMethod
rand_regular_bipartite_graph([rng=default_rng()], nleft, nright, k)

Create a bipartite graph with nleft nodes in the left block, nright nodes in the right block, where all left nodes have degree k.

source