|
def | __init__ (self) |
|
def | from_edges (cls, edge_iterable, get_node_1=operator.itemgetter(0), get_node_2=operator.itemgetter(1), get_node_id=lambda x:x, get_edge_id=lambda x:x) |
|
def | add_edge (self, edge, get_node_1=operator.itemgetter(0), get_node_2=operator.itemgetter(1), get_node_id=lambda x:x, get_edge_id=lambda x:x) |
|
def | get_edge_for_indices (self, node_index1, node_index2) |
|
def | get_indices_for_edge (self, edge) |
|
def | get_node_for_index (self, node_index) |
|
def | get_index_for_node (self, node) |
|
def | get_nof_nodes (self) |
|
def | get_edges (self) |
|
Object for holding a graph for calculations.
◆ __init__()
def py_rdl.Graph.Graph.__init__ |
( |
|
self | ) |
|
Create a new (empty) graph.
Use this method and add individual edges or
use from_edges instead.
◆ add_edge()
def py_rdl.Graph.Graph.add_edge |
( |
|
self, |
|
|
|
edge, |
|
|
|
get_node_1 = operator.itemgetter(0) , |
|
|
|
get_node_2 = operator.itemgetter(1) , |
|
|
|
get_node_id = lambda x: x , |
|
|
|
get_edge_id = lambda x: x |
|
) |
| |
Add an edge to this graph.
edge: edge to be added to the graph
get_node_1: function retrieving the first node of an edge
get_node_2: function retrieving the second node of an edge
get_node_id: fucntion for retrieving node identifier
get_edge_id: function for retrieving edge identifier
returns the edge_id if successfull, None if edge already present
(and warns in that case)
This function adds an edge to the graph.
DO NOT USE AFTER CALCULATION
◆ from_edges()
def py_rdl.Graph.Graph.from_edges |
( |
|
cls, |
|
|
|
edge_iterable, |
|
|
|
get_node_1 = operator.itemgetter(0) , |
|
|
|
get_node_2 = operator.itemgetter(1) , |
|
|
|
get_node_id = lambda x: x , |
|
|
|
get_edge_id = lambda x: x |
|
) |
| |
Create a new Graph datastructure
edge_iterable: an iterable containing the edges
get_node_1: function retrieving the first node of an edge
get_node_2: function retrieving the second node of an edge
get_node_id: function for retrieven node identifier
get_edge_id: function for retrieving edge identifier
This classmethod creates a new Graph.
The edge_iterable can be any iterable (list, generator etc.).
An edge can be as simple as a pair of nodes.
The get_node_ function must return the respective nodes adjacent
to an edge (default: first and second element of the edge).
The node must be hashable. If it's not, use some unique ID
instead.
The edge must be hashable. If it's not, use some unique ID
instead (provided by get_edge_id).
◆ get_edge_for_indices()
def py_rdl.Graph.Graph.get_edge_for_indices |
( |
|
self, |
|
|
|
node_index1, |
|
|
|
node_index2 |
|
) |
| |
Returns the edge which is formed by the two nodes
(as indices).
node_index1: index of the first node
node_index2: index of the second node
returns edge adjacent by two nodes
raises KeyError if the edge does not exist
This function is used internally by Calculator, you
probably won't need this function.
◆ get_edges()
def py_rdl.Graph.Graph.get_edges |
( |
|
self | ) |
|
Get the edges in the graph.
This function is used internally by Calculator, you
won't need this function.
◆ get_index_for_node()
def py_rdl.Graph.Graph.get_index_for_node |
( |
|
self, |
|
|
|
node |
|
) |
| |
Returns the internal index for the node.
node: node object
returns the index for the node object
raises KeyError if node does not exist
This function is used internally by Calculator, you
probably won't need this function.
◆ get_indices_for_edge()
def py_rdl.Graph.Graph.get_indices_for_edge |
( |
|
self, |
|
|
|
edge |
|
) |
| |
Returns the edge which is formed by the two nodes
(as indices).
edge: edge
returns edge adjacent by two nodes
raises KeyError if the edge does not exist
This function is used internally by Calculator, you
probably won't need this function.
◆ get_node_for_index()
def py_rdl.Graph.Graph.get_node_for_index |
( |
|
self, |
|
|
|
node_index |
|
) |
| |
Returns the node with the internal index.
node_index: index of the node
returns the node object with this index
raises IndexError if node does not exist
This function is used internally by Calculator, you
probably won't need this function.
◆ get_nof_nodes()
def py_rdl.Graph.Graph.get_nof_nodes |
( |
|
self | ) |
|
Get the number of nodes in the graph.
The documentation for this class was generated from the following file:
- src/python/py_rdl/Graph.py