Package networkx :: Package generators :: Module bipartite
[hide private]
[frames] | no frames]

Module bipartite

source code

Generators and functions for bipartite graphs.


Author: Aric Hagberg (hagberg@lanl.gov) Pieter Swart (swart@lanl.gov) Dan Schult (dschult@colgate.edu)

Functions [hide private]
 
bipartite_configuration_model(aseq, bseq, create_using=None, seed=None)
Return a random bipartite graph from two given degree sequences.
source code
 
bipartite_havel_hakimi_graph(aseq, bseq, create_using=None)
Return a bipartite graph from two given degree sequences using a Havel-Hakimi style construction.
source code
 
bipartite_reverse_havel_hakimi_graph(aseq, bseq, create_using=None)
Return a bipartite graph from two given degree sequences using a "reverse" Havel-Hakimi style construction.
source code
 
bipartite_alternating_havel_hakimi_graph(aseq, bseq, create_using=None)
Return a bipartite graph from two given degree sequences using a alternating Havel-Hakimi style construction.
source code
 
bipartite_preferential_attachment_graph(aseq, p, create_using=None)
Create a bipartite graph with a preferential attachment model from a given single "top" degree sequence.
source code
 
bipartite_random_regular_graph(d, n, create_using=None)
UNTESTED:Generate a random bipartite graph of n nodes each with degree d.
source code
 
project(B, nodes, create_using=None)
Returns a graph that is the projection of the bipartite graph B onto the set of nodes given in list nodes.
source code
 
bipartite_color(G) source code
 
is_bipartite(G)
Returns True if graph G is bipartite, False if not.
source code
 
bipartite_sets(G)
Returns (X,Y) where X and Y are the nodes in each bipartite set of graph G.
source code
 
_test_suite() source code
Function Details [hide private]

bipartite_configuration_model(aseq, bseq, create_using=None, seed=None)

source code 

Return a random bipartite graph from two given degree sequences.

Nodes from the set A are connected to nodes in the set B by choosing randomly from the possible free stubs, one in A and one in B.

The sum of the two sequences must be equal: sum(aseq)=sum(bseq)

If no graph type is specified use XGraph with parallel edges.

If you want a graph with no parallel edges use create_using=Graph() but then the resulting degree sequences might not be exact.

Parameters:
  • aseq - degree sequence for node set A
  • bseq - degree sequence for node set B

bipartite_havel_hakimi_graph(aseq, bseq, create_using=None)

source code 

Return a bipartite graph from two given degree sequences using a Havel-Hakimi style construction.

Nodes from the set A are connected to nodes in the set B by connecting the highest degree nodes in set A to the highest degree nodes in set B until all stubs are connected.

The sum of the two sequences must be equal: sum(aseq)=sum(bseq)

Parameters:
  • aseq - degree sequence for node set A
  • bseq - degree sequence for node set B

bipartite_reverse_havel_hakimi_graph(aseq, bseq, create_using=None)

source code 

Return a bipartite graph from two given degree sequences using a "reverse" Havel-Hakimi style construction.

Nodes from the set A are connected to nodes in the set B by connecting the highest degree nodes in set A to the lowest degree nodes in set B until all stubs are connected.

The sum of the two sequences must be equal: sum(aseq)=sum(bseq)

Parameters:
  • aseq - degree sequence for node set A
  • bseq - degree sequence for node set B

bipartite_alternating_havel_hakimi_graph(aseq, bseq, create_using=None)

source code 

Return a bipartite graph from two given degree sequences using a alternating Havel-Hakimi style construction.

Nodes from the set A are connected to nodes in the set B by connecting the highest degree nodes in set A to alternatively the highest and the lowest degree nodes in set B until all stubs are connected.

The sum of the two sequences must be equal: sum(aseq)=sum(bseq)

Parameters:
  • aseq - degree sequence for node set A
  • bseq - degree sequence for node set B

bipartite_preferential_attachment_graph(aseq, p, create_using=None)

source code 

Create a bipartite graph with a preferential attachment model from a given single "top" degree sequence.

Reference:

@article{guillaume-2004-bipartite,
  author = {Jean-Loup Guillaume and Matthieu Latapy},
  title = {Bipartite structure of all complex networks},
  journal = {Inf. Process. Lett.},
  volume = {90},
  number = {5},
  year = {2004},
  issn = {0020-0190},
  pages = {215--221},
  doi = {http://dx.doi.org/10.1016/j.ipl.2004.03.007},
  publisher = {Elsevier North-Holland, Inc.},
  address = {Amsterdam, The Netherlands, The Netherlands},
  }
Parameters:
  • aseq - degree sequence for node set A (top)
  • p - probability that a new bottom node is added

bipartite_random_regular_graph(d, n, create_using=None)

source code 

UNTESTED:Generate a random bipartite graph of n nodes each with degree d.

Restrictions on n and d:
  • n must be even
  • n>=2*d

Nodes are numbered 0...n-1.

Algorithm inspired by random_regular_graph()

project(B, nodes, create_using=None)

source code 

Returns a graph that is the projection of the bipartite graph B onto the set of nodes given in list nodes.

The nodes retain their names and are connected if they share a common node in the node set of {B not nodes }.

No attempt is made to verify that the input graph B is bipartite.

is_bipartite(G)

source code 

Returns True if graph G is bipartite, False if not.

Traverse the graph G with depth-first-search and color nodes.

bipartite_sets(G)

source code 
Returns (X,Y) where X and Y are the nodes in each bipartite set of graph G. Fails with an error if graph is not bipartite.