Inheritance diagram for nipy.algorithms.graph.bipartite_graph:
This module implements the BipartiteGraph class, used to represent weighted bipartite graph: it contains two types of vertices, say ‘left’ and ‘right’; then edges can only exist between ‘left’ and ‘right’ vertices. For simplicity the vertices of either side are labeled [1..V] and [1..W] respectively.
Author: Bertrand Thirion, 2006–2011
Bases: object
Bipartite graph class
A graph for which there are two types of nodes, such that edges can exist only between nodes of type 1 and type 2 (not within) fields of this class: V (int, > 0) the number of type 1 vertices W (int, > 0) the number of type 2 vertices E: (int) the number of edges edges: array of shape (self.E, 2) reprensenting pairwise neighbors weights, array of shape (self.E), +1/-1 for scending/descending links
Constructor
Parameters: | V (int), the number of vertices of subset 1 : W (int), the number of vertices of subset 2 : edges=None: array of shape (self.E, 2) :
weights=None: array of shape (self.E) :
|
---|
returns a copy of self
Set edges to graph
Parameters: | edges: array of shape(self.E, 2): set of candidate edges : |
---|
Set weights weights to edges
Parameters: | weights, array of shape(self.V): edges weights : |
---|
Extraction of a subgraph
Parameters: | valid, boolean array of shape self.V : renumb, boolean: renumbering of the (left) edges : |
---|---|
Returns: | G : None or BipartiteGraph instance
|
Extraction of a subgraph
Parameters: | valid : bool array of shape self.V renumb : bool, optional
|
---|---|
Returns: | G : None or BipartiteGraph instance.
|
Instantiates a weighted graph from a square 2D array
Parameters: | x: 2D array instance, the input array : |
---|---|
Returns: | wg: BipartiteGraph instance : |
Instantiates a weighted graph from a (sparse) coo_matrix
Parameters: | x: scipy.sparse.coo_matrix instance, the input matrix : |
---|---|
Returns: | bg: BipartiteGraph instance : |
checks wether the dismension of X and Y are consistent
Parameters: | X, Y arrays of shape (n1, p) and (n2, p) : where p = common dimension of the features : |
---|
Return the eps-neighbours graph of from X to Y
Parameters: | X, Y arrays of shape (n1, p) and (n2, p) : where p = common dimension of the features : eps=1, float: the neighbourhood size considered : |
---|---|
Returns: | the resulting bipartite graph instance : |
Notes
for the sake of speed it is advisable to give PCA-preprocessed matrices X and Y.
return the k-nearest-neighbours graph of from X to Y
Parameters: | X, Y arrays of shape (n1, p) and (n2, p) : where p = common dimension of the features : eps=1, float: the neighbourhood size considered : |
---|---|
Returns: | BipartiteGraph instance : |
Notes
For the sake of speed it is advised to give PCA-transformed matrices X and Y.