Package NX :: Module operators
[frames | no frames]

Module NX.operators

Operations on graphs; including union, complement, subgraph.


Function Summary
  cartesian_product(G, H)
Return the Cartesian product of G and H.
  complement(G, create_using, **kwds)
Return graph complement of G.
  compose(G, H, create_using, **kwds)
Return a new graph of G composed with H.
  convert_node_labels_to_integers(G, first_label, ordering, discard_old_labels)
Return a copy of G, with n node labels replaced with integers, starting at first_label.
  convert_to_directed(G)
Return a new directed representation of the graph G.
  convert_to_undirected(G)
Return a new undirected representation of the graph G.
  create_empty_copy(G)
Return a new, empty graph-like object of the same type/class as G.
  disjoint_union(G, H)
Return the disjoint union of graphs G and H, forcing distinct integer node labels.
  subgraph(G, nbunch, inplace, create_using, **kwds)
Return the subgraph induced on nodes in nbunch.
  union(G, H, create_using, rename, **kwds)
Return the union of graphs G and H.

Variable Summary
str __author__ = 'Aric Hagberg (hagberg@lanl.gov)\nPieter Sw...
str __credits__ = ''
str __date__ = '$Date: 2005/03/30 23:56:28 $'
str __revision__ = '$Revision: 1.24 $'

Function Details

cartesian_product(G, H)

Return the Cartesian product of G and H.

Tested only on Graph class.

complement(G, create_using=None, **kwds)

Return graph complement of G.

Unless otherwise specified, return a new graph of the same type as self. Use (optional) create_using=R to return the resulting subgraph in R. R can be an existing graph-like object (to be emptied) or R can be a call to a graph object, e.g. create_using=DiGraph(). See documentation for empty_graph()

Implemented for Graph, DiGraph, XGraph, XDiGraph. Note that complement() is not well-defined for XGraph and XDiGraph objects that allow multiple edges or self-loops.

compose(G, H, create_using=None, **kwds)

Return a new graph of G composed with H.

The node sets of G and H need not be disjoint.

A new graph is returned, of the same class as G. It is recommended that G and H be either both directed or both undirected.

Optional create_using=R returns graph R filled in with the compose(G,H). Otherwise a new graph is created, of the same class as G. It is recommended that G and H be either both directed or both undirected.

Implemented for Graph, DiGraph, XGraph, XDiGraph

convert_node_labels_to_integers(G, first_label=1, ordering='default', discard_old_labels=True)

Return a copy of G, with n node labels replaced with integers, starting at first_label.

first_label: (optional, default=1)
An integer specifying the offset in numbering nodes. The n new integer labels are numbered first_label, ..., n+first_label.
ordering: (optional, default="default")
specifies how nodes are ordered. Possible values: "default" (inherit from G), "increasing degree", or "decreasing degree"
discard_old_labels
if True (default) discard old labels if False, create a dict self.node_labels that maps new labels to old labels, and set self.dna["node_labeled"]=True

Works for Graph, DiGraph, XGraph, XDiGraph

convert_to_directed(G)

Return a new directed representation of the graph G.

Works for Graph, DiGraph, XGraph, XDiGraph.

Note: convert_to_directed(G)=G.to_directed()

convert_to_undirected(G)

Return a new undirected representation of the graph G.

Works for Graph, DiGraph, XGraph, XDiGraph.

Note: convert_to_undirected(G)=G.to_undirected()

create_empty_copy(G)

Return a new, empty graph-like object of the same type/class as G.

Works for Graph, DiGraph, XGraph, XDiGraph

disjoint_union(G, H)

Return the disjoint union of graphs G and H, forcing distinct integer node labels.

A new graph is created, of the same class as G. It is recommended that G and H be either both directed or both undirected.

Implemented for Graph, DiGraph, XGraph, XDiGraph.

subgraph(G, nbunch, inplace=False, create_using=None, **kwds)

Return the subgraph induced on nodes in nbunch.

nbunch: either a singleton node, a string (which is treated as a singleton node, or any iterable (non-string) container of nodes for which len(nbunch) is defined. For example, a list, dict, set, Graph, numeric array, or user-defined iterable object.

Setting inplace=True will return induced subgraph in original graph by deleting nodes not in nbunch.

Unless otherwise specified, return a new graph of the same type as self. Use (optional) create_using=R to return the resulting subgraph in R. R can be an existing graph-like object (to be emptied) or R is a call to a graph object, e.g. create_using=DiGraph(). See documentation for empty_graph.

Implemented for Graph, DiGraph, XGraph, XDiGraph

Note: subgraph(G) calls G.subgraph()

union(G, H, create_using=None, rename=False, **kwds)

Return the union of graphs G and H.

Graphs G and H must be disjoint, otherwise an exception is raised.

Node names of G and H can be changed be specifying the tuple rename=('G-','H-') (for example). Node u in G is then renamed "G-u" and v in H is renamed "H-v".

To force a disjoint union with node relabeling, use disjoint_union(G,H) or convert_node_labels_to integers().

Optional create_using=R returns graph R filled in with the union of G and H. Otherwise a new graph is created, of the same class as G. It is recommended that G and H be either both directed or both undirected.

A new name can be specified in the form X=graph_union(G,H,name="new_name")

Implemented for Graph, DiGraph, XGraph, XDiGraph.


Variable Details

__author__

Type:
str
Value:
'''Aric Hagberg (hagberg@lanl.gov)
Pieter Swart (swart@lanl.gov)
Dan Schult(dschult@colgate.edu)'''                                     

__credits__

Type:
str
Value:
''                                                                     

__date__

Type:
str
Value:
'$Date: 2005/03/30 23:56:28 $'                                         

__revision__

Type:
str
Value:
'$Revision: 1.24 $'                                                    

Generated by Epydoc 2.1 on Mon Apr 11 10:59:21 2005 http://epydoc.sf.net