Package graph :: Package classes :: Module Hypergraph :: Class hypergraph

Class hypergraph

object --+
         |
        hypergraph

Hypergraph class.

Hypergraphs are a generalization of graphs where an edge (called hyperedge) can connect more than two nodes.

Instance Methods
 
__init__(self)
Initialize a hypergraph.
number
__len__(self)
Return the size of the hypergraph when requested by len().
string
__str__(self)
Return a string representing the hypergraph when requested by str() (or print).
 
add_hyperedge(self, hyperedge)
Add given hyperedge to the hypergraph.
 
add_hyperedges(self, edgelist)
Add given hyperedges to the hypergraph.
 
add_node(self, node)
Add given node to the hypergraph.
 
add_nodes(self, nodelist)
Add given nodes to the hypergraph.
boolean
has_node(self, node)
Return whether the requested node exists.
list
hyperedges(self)
Return hyperedge list.
 
link(self, node, hyperedge)
Link given node and hyperedge.
list
links(self, obj)
Return all objects linked to the given one.
list
nodes(self)
Return node list.
 
unlink(self, node, hyperedge)
Unlink given node and hyperedge.
 
read(self, string, fmt='xml')
Read a hypergraph from a string.
string
write(self, fmt='xml')
Write the hypergraph to a string.
dictionary
accessibility(self)
Accessibility matrix (transitive closure).
dictionary
connected_components(self)
Connected components.
list
cut_hyperedges(self)
Return the cut-hyperedges of the given hypergraph.
list
cut_nodes(self)
Return the cut-nodes of the given hypergraph.
int
rank(self)
Return the rank of the given hypergraph.

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__

Properties

Inherited from object: __class__

Method Details

__init__(self)
(Constructor)

 

Initialize a hypergraph.

Overrides: object.__init__

__len__(self)
(Length operator)

 

Return the size of the hypergraph when requested by len().

Returns: number
Size of the hypergraph.

__str__(self)
(Informal representation operator)

 

Return a string representing the hypergraph when requested by str() (or print).

Returns: string
String representing the hypergraph.
Overrides: object.__str__

add_hyperedge(self, hyperedge)

 

Add given hyperedge to the hypergraph.

Parameters:
  • hyperedge (hyperedge) - Hyperedge identifier.

Attention: While hyperedge-nodes can be of any type, it's strongly recommended to use only numbers and single-line strings as node identifiers if you intend to use write().

add_hyperedges(self, edgelist)

 

Add given hyperedges to the hypergraph.

Parameters:
  • edgelist (list) - List of hyperedge-nodes to be added to the graph.

Attention: While hyperedge-nodes can be of any type, it's strongly recommended to use only numbers and single-line strings as node identifiers if you intend to use write().

add_node(self, node)

 

Add given node to the hypergraph.

Parameters:
  • node (node) - Node identifier.

Attention: While nodes can be of any type, it's strongly recommended to use only numbers and single-line strings as node identifiers if you intend to use write().

add_nodes(self, nodelist)

 

Add given nodes to the hypergraph.

Parameters:
  • nodelist (list) - List of nodes to be added to the graph.

Attention: While nodes can be of any type, it's strongly recommended to use only numbers and single-line strings as node identifiers if you intend to use write().

has_node(self, node)

 

Return whether the requested node exists.

Parameters:
  • node (node) - Node identifier
Returns: boolean
Truth-value for node existence.

hyperedges(self)

 

Return hyperedge list.

Returns: list
List of hyperedges linked to the given node.

link(self, node, hyperedge)

 

Link given node and hyperedge.

Parameters:
  • node (node) - Node.
  • hyperedge (node) - Hyperedge.

links(self, obj)

 

Return all objects linked to the given one.

If given a node, linked hyperedges will be returned. If given a hyperedge, linked nodes will be returned.

Parameters:
  • obj (node or hyperedge) - Object identifier.
Returns: list
List of objects linked to the given one.

nodes(self)

 

Return node list.

Returns: list
Node list.

unlink(self, node, hyperedge)

 

Unlink given node and hyperedge.

Parameters:
  • node (node) - Node.
  • hyperedge (hyperedge) - Hyperedge.

read(self, string, fmt='xml')

 

Read a hypergraph from a string. Nodes and hyperedges specified in the input will be added to the current graph.

Parameters:
  • string (string) - Input string specifying a graph.
  • fmt (string) - Input format. Possible formats are:
    1. 'xml' - XML (default)

write(self, fmt='xml')

 

Write the hypergraph to a string. Depending of the output format, this string can be used by read() to rebuild the graph.

Parameters:
  • fmt (string) - Output format. Possible formats are:
    1. 'xml' - XML (default)
    2. 'dot' - DOT Language (for GraphViz)
    3. 'dotclr' - DOT Language, coloured
Returns: string
String specifying the graph.

accessibility(self)

 

Accessibility matrix (transitive closure).

Returns: dictionary
Accessibility information for each node.

connected_components(self)

 

Connected components.

Returns: dictionary
Pairing that associates each node to its connected component.

cut_hyperedges(self)

 

Return the cut-hyperedges of the given hypergraph.

Returns: list
List of cut-nodes.

cut_nodes(self)

 

Return the cut-nodes of the given hypergraph.

Returns: list
List of cut-nodes.

rank(self)

 

Return the rank of the given hypergraph.

Returns: int
Rank of graph.