Package onep :: Package topology :: Module Graph :: Class Graph
[frames] | no frames]

Class Graph


The Graph class represents the topology graph as seen by a protocol from a node. A Graph object contains a collection of Edge objects.

Instance Methods
 
update(self, event_type, list)
Updates the topology graph object with a list of objects passed, based on the topology change events.
 
concatenate(self, other)
Concatenate this Graph object with another.
 
get_edge_list(self, edge_type)
Get the list of edges based on the directionality in a grpah The method returns a set of edges based on the direction requested if DIRECTED edges are requested then the edges to/from Node A and Node B are treated as different edges and both edges are returned.
list of Edge
get_edge_list_by_node(self, edge_type, node)
Get the edges connected with specified node in a given direction If the input edge_type is DIRECTED then graph is asymmetric If the edge_type is UNDIRECTED then graph is symmetric
 
get_connector_list_by_node(self, node)
Get the node connectors associated with specified node in the graph This method returns the list of node connectors associated with a node in a graph.
 
__str__(self)
str(x)

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __init__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __subclasshook__

Class Variables
  node_list = property(_get_node_list, None, _doc)
  type = property(_get_type, None, _doc)
Properties

Inherited from object: __class__

Method Details

update(self, event_type, list)

 

Updates the topology graph object with a list of objects passed, based on the topology change events. If the event is:

ONEP_TOPOLOGY_EDGES_ADD - The list should contain a set of EDGE object that needs to be added to the graph object.

ONEP_TOPOLOGY_EDGES_DELETE - The list should contain a set of EDGE objects that needs to be removed from the graph object.

ONEP_TOPOLOGY_NODES_ADD - The list should contain a set of nodes that needs to be added to the graph object.

ONEP_TOPOLOGY_NODES_DELETE - The list should contain a set of nodes that needs to be remove to the graph object. Removing a node from a graph would also result in removing all IN bound and OUT bound edges associated with the node.

Note: Adding a node to a graph would only reflect in the output of get_node_list() method, and the node remains orphaned.

Parameters:
  • event_type (enum) - Type of topology change event.
  • list (list) - List of edges or nodes that needs to be updated based on
Raises:

concatenate(self, other)

 

Concatenate this Graph object with another. The result graph is stored in this instance of Graph. Equal nodes(NodeA, NodeA') from the two graphs and their corresponding edges are merged to form a single node, the new node contains the edges from both the nodes(NodeA, NodeA'). If there are equal edges(with the same head and tail node connectors) in the two graphs, only one is retained in the original graph

Two CDP nodes are equal if they have same management IP and the hostname.

Two CDP connectors are equal if they have the same IP and the interface name.

Parameters:
  • other (Graph) - The other Graph object to be concatenated with.
Raises:

get_edge_list(self, edge_type)

 

Get the list of edges based on the directionality in a grpah The method returns a set of edges based on the direction requested if DIRECTED edges are requested then the edges to/from Node A and Node B are treated as different edges and both edges are returned. If UNDIRECTED edges are requested then the graph is assumed symmetric and only one edge in this case is returned

Parameters:
  • edge_type (list of Edge) - Type of edge either DIRECTED or UNDIRECTED. If the input is None, default type DIRECTED will be used

get_edge_list_by_node(self, edge_type, node)

 

Get the edges connected with specified node in a given direction If the input edge_type is DIRECTED then graph is asymmetric If the edge_type is UNDIRECTED then graph is symmetric

Parameters:
  • edge_type (Enum) - The direction of the edge
  • node (Node) - The node of interest. The Node object must contain the node name
Returns: list of Edge
A list of Edges. If no match found empty list is returned

get_connector_list_by_node(self, node)

 

Get the node connectors associated with specified node in the graph This method returns the list of node connectors associated with a node in a graph. Every time a graph is concatenated with another and if new set of node connectors are added to the graph, the list returned would be different.

Parameters:
  • node (Node @return : A list of NodeConnector. If no match is found, empty list is returned. Since the input node can match head node or tail node of a connector , it is possible the return list contains duplicate connectors) - The node of interest

__str__(self)
(Informal representation operator)

 

str(x)

Overrides: object.__str__
(inherited documentation)