BipartiteGraph

(Source code, png, hires.png, pdf)

../../_images/BipartiteGraph.png
class BipartiteGraph(*args)

Bipartite red/black graph.

Available constructors:

BipartiteGraph(size=0)

BipartiteGraph(sequence)

Parameters:

size : int, size \geq 0

Size of the collection.

sequence : sequence of Indices

Cliques of the red nodes.

Notes

A bipartite graph is an undirected graph in which the nodes can be colored in two colors such that no edge has its two ends with the same colors. Here we force the n red nodes to be numbered in consecutive order from 0 to n-1 and for each red node we give the list of black nodes that are the other end of the edges starting from this red node.

Examples

>>> import openturns as ot

Use the first constructor:

>>> ot.BipartiteGraph(3)
[[],[],[]]

Use the second constructor:

>>> graph = ot.BipartiteGraph([[1, 3], [2, 0], [5, 4]])
>>> graph
[[1,3],[2,0],[5,4]]

Use some functionalities:

>>> graph[1] = [3, 4]
>>> graph
[[1,3],[3,4],[5,4]]
>>> graph.add([1, 6])
>>> graph
[[1,3],[3,4],[5,4],[1,6]]

Methods

add(*args) Append a component (in-place).
at(*args) Access to an element of the collection.
clear() Reset the collection to zero dimension.
draw() Draw the graph.
getBlackNodes() Accessor to the graph black nodes.
getClassName() Accessor to the object’s name.
getId() Accessor to the object’s id.
getName() Accessor to the object’s name.
getRedNodes() Accessor to the graph red nodes.
getShadowedId() Accessor to the object’s shadowed id.
getSize() Get the collection’s dimension (or size).
getVisibility() Accessor to the object’s visibility state.
hasName() Test if the object is named.
hasVisibleName() Test if the object has a distinguishable name.
isEmpty() Tell if the collection is empty.
resize(newSize) Change the size of the collection.
setName(name) Accessor to the object’s name.
setShadowedId(id) Accessor to the object’s shadowed id.
setVisibility(visible) Accessor to the object’s visibility state.
__init__(*args)

x.__init__(…) initializes x; see help(type(x)) for signature

add(*args)

Append a component (in-place).

Parameters:

value : type depends on the type of the collection.

The component to append.

Examples

>>> import openturns as ot
>>> x = ot.Point(2)
>>> x.add(1.)
>>> print(x)
[0,0,1]
at(*args)

Access to an element of the collection.

Parameters:

index : positive int

Position of the element to access.

Returns:

element : type depends on the type of the collection

Element of the collection at the position index.

clear()

Reset the collection to zero dimension.

Examples

>>> import openturns as ot
>>> x = ot.Point(2)
>>> x.clear()
>>> x
class=Point name=Unnamed dimension=0 values=[]
draw()

Draw the graph.

Returns:

graph : a Graph

View of the bipartite graph as a set of red nodes linked to black nodes.

getBlackNodes()

Accessor to the graph black nodes.

Returns:black : sequence of int, Indices
getClassName()

Accessor to the object’s name.

Returns:

class_name : str

The object class name (object.__class__.__name__).

getId()

Accessor to the object’s id.

Returns:

id : int

Internal unique identifier.

getName()

Accessor to the object’s name.

Returns:

name : str

The name of the object.

getRedNodes()

Accessor to the graph red nodes.

Returns:red : sequence of int, Indices
getShadowedId()

Accessor to the object’s shadowed id.

Returns:

id : int

Internal unique identifier.

getSize()

Get the collection’s dimension (or size).

Returns:

n : int

The number of components in the collection.

getVisibility()

Accessor to the object’s visibility state.

Returns:

visible : bool

Visibility flag.

hasName()

Test if the object is named.

Returns:

hasName : bool

True if the name is not empty.

hasVisibleName()

Test if the object has a distinguishable name.

Returns:

hasVisibleName : bool

True if the name is not empty and not the default one.

isEmpty()

Tell if the collection is empty.

Returns:

isEmpty : bool

True if there is no element in the collection.

Examples

>>> import openturns as ot
>>> x = ot.Point(2)
>>> x.isEmpty()
False
>>> x.clear()
>>> x.isEmpty()
True
resize(newSize)

Change the size of the collection.

Parameters:

newSize : positive int

New size of the collection.

Notes

If the new size is smaller than the older one, the last elements are thrown away, else the new elements are set to the default value of the element type.

Examples

>>> import openturns as ot
>>> x = ot.Point(2, 4)
>>> print(x)
[4,4]
>>> x.resize(1)
>>> print(x)
[4]
>>> x.resize(4)
>>> print(x)
[4,0,0,0]
setName(name)

Accessor to the object’s name.

Parameters:

name : str

The name of the object.

setShadowedId(id)

Accessor to the object’s shadowed id.

Parameters:

id : int

Internal unique identifier.

setVisibility(visible)

Accessor to the object’s visibility state.

Parameters:

visible : bool

Visibility flag.