rez.vendor.pygraph.classes.hypergraph

Hypergraph class

class rez.vendor.pygraph.classes.hypergraph.hypergraph

Bases: basegraph, common, labeling

Hypergraph class.

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

@sort: __init__, __len__, __str__, add_hyperedge, add_hyperedges, add_node, add_nodes, del_edge, has_node, has_edge, has_hyperedge, hyperedges, link, links, nodes, unlink

DIRECTED = True
__init__()

Initialize a hypergraph.

nodes()

Return node list.

@rtype: list @return: Node list.

edges()

Return the hyperedge list.

@rtype: list @return: List of hyperedges in the graph.

hyperedges()

Return hyperedge list.

@rtype: list @return: List of hyperedges in the graph.

has_edge(hyperedge)

Return whether the requested node exists.

@type hyperedge: hyperedge @param hyperedge: Hyperedge identifier

@rtype: boolean @return: Truth-value for hyperedge existence.

has_hyperedge(hyperedge)

Return whether the requested node exists.

@type hyperedge: hyperedge @param hyperedge: Hyperedge identifier

@rtype: boolean @return: Truth-value for hyperedge existence.

Return all nodes connected by the given hyperedge or all hyperedges connected to the given hypernode.

@type obj: hyperedge @param obj: Object identifier.

@rtype: list @return: List of node objects linked to the given hyperedge.

neighbors(obj)

Return all neighbors adjacent to the given node.

@type obj: node @param obj: Object identifier.

@rtype: list @return: List of all node objects adjacent to the given node.

has_node(node)

Return whether the requested node exists.

@type node: node @param node: Node identifier

@rtype: boolean @return: Truth-value for node existence.

add_node(node)

Add given node to the hypergraph.

@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().

@type node: node @param node: Node identifier.

del_node(node)

Delete a given node from the hypergraph.

@type node: node @param node: Node identifier.

add_edge(hyperedge)

Add given hyperedge to the hypergraph.

@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().

@type hyperedge: hyperedge @param hyperedge: Hyperedge identifier.

add_hyperedge(hyperedge)

Add given hyperedge to the hypergraph.

@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().

@type hyperedge: hyperedge @param hyperedge: Hyperedge identifier.

add_edges(edgelist)

Add given hyperedges to the hypergraph.

@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().

@type edgelist: list @param edgelist: List of hyperedge-nodes to be added to the graph.

add_hyperedges(edgelist)

Add given hyperedges to the hypergraph.

@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().

@type edgelist: list @param edgelist: List of hyperedge-nodes to be added to the graph.

del_edge(hyperedge)

Delete the given hyperedge.

@type hyperedge: hyperedge @param hyperedge: Hyperedge identifier.

del_hyperedge(hyperedge)

Delete the given hyperedge.

@type hyperedge: hyperedge @param hyperedge: Hyperedge identifier.

Link given node and hyperedge.

@type node: node @param node: Node.

@type hyperedge: node @param hyperedge: Hyperedge.

Unlink given node and hyperedge.

@type node: node @param node: Node.

@type hyperedge: hyperedge @param hyperedge: Hyperedge.

rank()

Return the rank of the given hypergraph.

@rtype: int @return: Rank of graph.

DEFAULT_LABEL = ''
DEFAULT_WEIGHT = 1
LABEL_ATTRIBUTE_NAME = 'label'
WEIGHT_ATTRIBUTE_NAME = 'weight'
add_edge_attribute(edge, attr)

Add attribute to the given edge.

@type edge: edge @param edge: One edge.

@type attr: tuple @param attr: Node attribute specified as a tuple in the form (attribute, value).

add_edge_attributes(edge, attrs)

Append a sequence of attributes to the given edge

@type edge: edge @param edge: One edge.

@type attrs: tuple @param attrs: Node attributes specified as a sequence of tuples in the form (attribute, value).

add_graph(other)

Add other graph to this graph.

@attention: Attributes and labels are not preserved.

@type other: graph @param other: Graph

add_node_attribute(node, attr)

Add attribute to the given node.

@type node: node @param node: Node identifier

@type attr: tuple @param attr: Node attribute specified as a tuple in the form (attribute, value).

add_nodes(nodelist)

Add given nodes 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(). Objects used to identify nodes absolutely must be hashable. If you need attach a mutable or non-hashable node, consider using the labeling feature.

@type nodelist: list @param nodelist: List of nodes to be added to the graph.

add_spanning_tree(st)

Add a spanning tree to the graph.

@type st: dictionary @param st: Spanning tree.

complete()

Make the graph a complete graph.

@attention: This will modify the current graph.

del_edge_labeling(edge)
del_node_labeling(node)
edge_attributes(edge)

Return the attributes of the given edge.

@type edge: edge @param edge: One edge.

@rtype: list @return: List of attributes specified tuples in the form (attribute, value).

edge_label(edge)

Get the label of an edge.

@type edge: edge @param edge: One edge.

@rtype: string @return: Edge label

edge_weight(edge)

Get the weight of an edge.

@type edge: edge @param edge: One edge.

@rtype: number @return: Edge weight.

get_edge_properties(edge)
inverse()

Return the inverse of the graph.

@rtype: graph @return: Complement graph for the graph.

node_attributes(node)

Return the attributes of the given node.

@type node: node @param node: Node identifier

@rtype: list @return: List of attributes specified tuples in the form (attribute, value).

order()

Return the order of self, this is defined as the number of nodes in the graph.

@rtype: number @return: Size of the graph.

reverse()

Generate the reverse of a directed graph, returns an identical graph if not directed. Attributes & weights are preserved.

@rtype: digraph @return: The directed graph that should be reversed.

set_edge_label(edge, label)

Set the label of an edge.

@type edge: edge @param edge: One edge.

@type label: string @param label: Edge label.

set_edge_properties(edge, **properties)
set_edge_weight(edge, wt)

Set the weight of an edge.

@type edge: edge @param edge: One edge.

@type wt: number @param wt: Edge weight.