Interface IVertexBiPartition
-
- All Superinterfaces:
IVertexPartition
,VertexBiPartition<Integer,Integer>
,VertexPartition<Integer,Integer>
public interface IVertexBiPartition extends IVertexPartition, VertexBiPartition<Integer,Integer>
A partition of the vertices of an int graph into two blocks.This interface is a specification of
VertexBiPartition
forIntGraph
. SeeVertexBiPartition
for the complete documentation.- Author:
- Barak Ugav
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description default IntSet
crossEdges()
Get the edges that cross between the left and right blocks.static IVertexBiPartition
fromBitmap(IndexGraph g, com.jgalgo.internal.util.Bitmap bitmap)
Create a new vertex bi-partition from a bitmap.static IVertexBiPartition
fromMap(IntGraph g, Map<Integer,Boolean> map)
Create a new vertex bi-partition from a vertex-side map.static IVertexBiPartition
fromMapping(IntGraph g, IntPredicate mapping)
Create a new vertex bi-partition from a vertex-side mapping function.static IVertexBiPartition
fromWeights(IntGraph g, IWeightsBool weights)
Create a new vertex bi-partition from a vertex-side weights container.boolean
isLeft(int vertex)
Check whether a vertex is contained in the left block (block 0).default boolean
isLeft(Integer vertex)
Deprecated.Please useisLeft(int)
instead to avoid un/boxing.static boolean
isPartition(IntGraph g, IntPredicate mapping)
Check if a mapping is a valid bi-partition of the vertices of a graph.default boolean
isRight(int vertex)
Check whether a vertex is contained in the right block (block 1).default boolean
isRight(Integer vertex)
Deprecated.Please useisRight(int)
instead to avoid un/boxing.default IntSet
leftEdges()
Get the edges that are contained in the left block.default IntSet
leftVertices()
Get the vertices in the 'left' block.default IntSet
rightEdges()
Get the edges that are contained in the right block.default IntSet
rightVertices()
Get the vertices in the 'right' block.default int
vertexBlock(int vertex)
Get the block containing a vertex.default int
vertexBlock(Integer vertex)
Deprecated.Please usevertexBlock(int)
instead to avoid un/boxing.-
Methods inherited from interface com.jgalgo.alg.common.IVertexPartition
blockEdges, blocksGraph, blocksGraph, blockSubGraph, blockSubGraph, blockVertices, crossEdges, graph
-
Methods inherited from interface com.jgalgo.alg.common.VertexBiPartition
numberOfBlocks
-
-
-
-
Method Detail
-
isLeft
boolean isLeft(int vertex)
Check whether a vertex is contained in the left block (block 0).- Parameters:
vertex
- a vertex in the graph- Returns:
true
if the vertex is contained in the left block,false
otherwise
-
isLeft
@Deprecated default boolean isLeft(Integer vertex)
Deprecated.Please useisLeft(int)
instead to avoid un/boxing.Check whether a vertex is contained in the left block (block 0).- Specified by:
isLeft
in interfaceVertexBiPartition<Integer,Integer>
- Parameters:
vertex
- a vertex in the graph- Returns:
true
if the vertex is contained in the left block,false
otherwise
-
isRight
default boolean isRight(int vertex)
Check whether a vertex is contained in the right block (block 1).- Parameters:
vertex
- a vertex in the graph- Returns:
true
if the vertex is contained in the right block,false
otherwise
-
isRight
@Deprecated default boolean isRight(Integer vertex)
Deprecated.Please useisRight(int)
instead to avoid un/boxing.Check whether a vertex is contained in the right block (block 1).- Specified by:
isRight
in interfaceVertexBiPartition<Integer,Integer>
- Parameters:
vertex
- a vertex in the graph- Returns:
true
if the vertex is contained in the right block,false
otherwise
-
vertexBlock
default int vertexBlock(int vertex)
Description copied from interface:IVertexPartition
Get the block containing a vertex.- Specified by:
vertexBlock
in interfaceIVertexPartition
- Parameters:
vertex
- a vertex in the graph- Returns:
- index of the block containing the vertex, in range \([0, blocksNum)\)
-
vertexBlock
@Deprecated default int vertexBlock(Integer vertex)
Deprecated.Please usevertexBlock(int)
instead to avoid un/boxing.Get the block containing a vertex.- Specified by:
vertexBlock
in interfaceIVertexPartition
- Specified by:
vertexBlock
in interfaceVertexBiPartition<Integer,Integer>
- Specified by:
vertexBlock
in interfaceVertexPartition<Integer,Integer>
- Parameters:
vertex
- a vertex in the graph- Returns:
- index of the block containing the vertex, in range \([0, blocksNum)\)
-
leftVertices
default IntSet leftVertices()
Description copied from interface:VertexBiPartition
Get the vertices in the 'left' block.The left block is the block with index 0.
- Specified by:
leftVertices
in interfaceVertexBiPartition<Integer,Integer>
- Returns:
- the vertices in the left block
-
rightVertices
default IntSet rightVertices()
Description copied from interface:VertexBiPartition
Get the vertices in the 'right' block.The right block is the block with index 1.
- Specified by:
rightVertices
in interfaceVertexBiPartition<Integer,Integer>
- Returns:
- the vertices in the right block
-
leftEdges
default IntSet leftEdges()
Description copied from interface:VertexBiPartition
Get the edges that are contained in the left block.The left block is the block with index 0, and edges contained in it are edges with both endpoints in the left block.
- Specified by:
leftEdges
in interfaceVertexBiPartition<Integer,Integer>
- Returns:
- the edges that are contained in the left block
-
rightEdges
default IntSet rightEdges()
Description copied from interface:VertexBiPartition
Get the edges that are contained in the right block.The right block is the block with index 1, and edges contained in it are edges with both endpoints in the right block.
- Specified by:
rightEdges
in interfaceVertexBiPartition<Integer,Integer>
- Returns:
- the edges that are contained in the right block
-
crossEdges
default IntSet crossEdges()
Description copied from interface:VertexBiPartition
Get the edges that cross between the left and right blocks.An edge \((u,v)\) is said to cross between two blocks \(b_1\) and \(b_2\) if \(u\) is contained in \(b_1\) and \(v\) is contained in \(b_2\). Note that if the graph is directed, the cross edges of \((b_1,b_2)\) are different that \((b_2,b_1)\), since the direction of the edge matters. In that case, the edges returned by this functions are edges sourced in the left block and targeted in the right block. To get the edges sourced in the right block and targeted in the left block, use
crossEdges(1, 0)
.- Specified by:
crossEdges
in interfaceVertexBiPartition<Integer,Integer>
- Returns:
- the edges that cross between the left and right blocks
-
fromMap
static IVertexBiPartition fromMap(IntGraph g, Map<Integer,Boolean> map)
Create a new vertex bi-partition from a vertex-side map.Note that this function does not validate the input. For that, see
isPartition(IntGraph, IntPredicate)
.- Parameters:
g
- the graphmap
- a map from vertex to eithertrue
orfalse
- Returns:
- a new vertex bi-partition
-
fromMapping
static IVertexBiPartition fromMapping(IntGraph g, IntPredicate mapping)
Create a new vertex bi-partition from a vertex-side mapping function.Note that this function does not validate the input. For that, see
isPartition(IntGraph, IntPredicate)
.- Parameters:
g
- the graphmapping
- a mapping function that maps from a vertex to eithertrue
orfalse
, wheretrue
means the vertex is contained in the left block andfalse
means the vertex is contained in the right block- Returns:
- a new vertex bi-partition
-
fromWeights
static IVertexBiPartition fromWeights(IntGraph g, IWeightsBool weights)
Create a new vertex bi-partition from a vertex-side weights container.- Parameters:
g
- the graphweights
- a weights container that maps from a vertex to eithertrue
orfalse
, wheretrue
means the vertex is contained in the left block andfalse
means the vertex is contained in the right block- Returns:
- a new vertex bi-partition
-
fromBitmap
static IVertexBiPartition fromBitmap(IndexGraph g, com.jgalgo.internal.util.Bitmap bitmap)
Create a new vertex bi-partition from a bitmap.This function can be used only for index graphs.
- Parameters:
g
- the index graphbitmap
- a bitmap wheretrue
means the vertex is contained in the left block andfalse
means the vertex is contained in the right block. The bitmap is not copied, and it is assumed the caller of this function will not modify the bitmap after calling this function- Returns:
- a new vertex bi-partition
-
isPartition
static boolean isPartition(IntGraph g, IntPredicate mapping)
Check if a mapping is a valid bi-partition of the vertices of a graph.A valid vertex bi-partition is a mapping from each vertex to either
true
orfalse
, in which there are not 'empty blocks', namely at least one vertex is mapped totrue
and another one is mapped totrue
.- Parameters:
g
- the graphmapping
- a mapping function that maps from a vertex to eithertrue
orfalse
- Returns:
true
if the mapping is a valid bi-partition of the vertices of the graph,false
otherwise
-
-