rez.vendor.pygraph.classes.digraph¶
Digraph class
- class rez.vendor.pygraph.classes.digraph.digraph¶
Bases:
basegraph,common,labelingDigraph class.
Digraphs are built of nodes and directed edges.
@sort: __eq__, __init__, __ne__, add_edge, add_node, del_edge, del_node, edges, has_edge, has_node, incidents, neighbors, node_order, nodes
- DIRECTED = True¶
- __init__()¶
Initialize a digraph.
- nodes()¶
Return node list.
@rtype: list @return: Node list.
- neighbors(node)¶
Return all nodes that are directly accessible from given node.
@type node: node @param node: Node identifier
@rtype: list @return: List of nodes directly accessible from given node.
- incidents(node)¶
Return all nodes that are incident to the given node.
@type node: node @param node: Node identifier
@rtype: list @return: List of nodes directly accessible from given node.
- edges()¶
Return all edges in the graph.
@rtype: list @return: List of all edges in the graph.
- 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, attrs=None)¶
Add given node 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().
@type node: node @param node: Node identifier.
@type attrs: list @param attrs: List of node attributes specified as (attribute, value) tuples.
- add_edge(edge, wt=1, label='', attrs=[])¶
Add an directed edge to the graph connecting two nodes.
An edge, here, is a pair of nodes like C{(n, m)}.
@type edge: tuple @param edge: Edge.
@type wt: number @param wt: Edge weight.
@type label: string @param label: Edge label.
@type attrs: list @param attrs: List of node attributes specified as (attribute, value) tuples.
- del_node(node)¶
Remove a node from the graph.
@type node: node @param node: Node identifier.
- del_edge(edge)¶
Remove an directed edge from the graph.
@type edge: tuple @param edge: Edge.
- has_edge(edge)¶
Return whether an edge exists.
@type edge: tuple @param edge: Edge.
@rtype: boolean @return: Truth-value for edge existence.
- node_order(node)¶
Return the order of the given node.
@rtype: number @return: Order of the given node.
- 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.