GraphNode
index
../../../../piana/code/Graph/GraphNode.py

File     : GraphNode.py
Author   : Daniel Jaeggi and Ramon Aragues
Creation : 2003
Contents : main class providing graph processing methods
Comments :
 
 
=======================================================================================================
A basic class defining a node in a graph.
 
The basic node class on which the graph is built.
Must be given unique nodeID.
Optionally given an attribute object GraphNodeAttribute.

 
Modules
       
sys

 
Classes
       
GraphNode

 
class GraphNode
    A basic class defining a node in a graph.
 
The basic node class on which the graph is built.
Must be given unique nodeID.
Optionally given an attribute object GraphNodeAttribute.
 
  Methods defined here:
__eq__(self, other)
__ge__(self, other)
__gt__(self, other)
__init__(self, nodeID, attribute=None, isRoot=0, graph=None, expanded_from=None, expansion_type=None, ishidden=0, alternative_id=None, original=0, level=-1)
__le__(self, other)
__lt__(self, other)
__ne__(self, other)
__repr__(self)
__str__(self)
add_edges(self, list_partners_ids)
Adds edges from list_edges to node.edges, after checking they do not exist already
 
This is used to update in the node which neighbours it currently has in the graph
add_root_connections(self, root_node_id, depth, antecessor)
Adds a node_id to the dictionary of root connections
 
If the connection existed previously with this root node, the minimum depth is taken
delete_partner(self, partner_node_id)
Deletes from this node the neighbour identified with "parnter_node_id" node_id
 
If the node does not exist, gives error
get_all_root_connections(self)
get_antecessor_to_root(self, root_node_id)
Returns the set of antecessors to arrive to root_node_id (not all antecessors, only the first ones)
get_degree(self, all=0)
Returns the nodal degree taking into account hidden edges which
are not included. This is the default behaviour.
If all is set to true, hidden edges will also be included.
get_edge_ids(self, filter_mode='all')
Return a list of edge ids where node participates
 
filter_mode not working at the minute. Future usage will be:
    -> will not return nodes if the node is hidden or the edge connecting them is hidden.
    -> if filter_mode=="all" is set true, will return all nodes irrespective of hidden status
get_graph(self)
returns the graph object associated to node
get_minimum_distance_to_root(self, root_node_id)
Returns the minimum distance of this node with the root identified by "root_node_id"
 
If there is no connection, returns None
get_neighbour_ids(self, all=0)
Return a list of neighbouring nodes.
 
 
Attention! argument 'all' not working.
    Normally: Will not return nodes if the node is hidden or the edge connecting them is hidden.
       -> If "all" is set true, will return all nodes irrespective of hidden status
get_neighbour_ids_set(self, all=0)
Return a dic of neighbouring nodes.
 
Attention! argument 'all' not working.
    Normally: Will not return nodes if the node is hidden or the edge connecting them is hidden.
       -> If "all" is set true, will return all nodes irrespective of hidden status
get_node_alternative_id(self)
returns the alternative node id of this node
get_node_attribute_object(self)
returns list of GraphNodeAttribute objects
get_node_id(self)
returns the node id of this node
get_number_neighbours(self)
returns the number of neighbours of this node in the graph where it belongs
get_number_shared_neighbours(self, other_node_neighbours_ids_set)
returns the number of neighbours of self node that are as well in other_node_neighbours_ids_list (which is a list with neighbours of another node)
get_partners_ids(self)
Returns a list of the ids for the neighbours of the node
get_root_connections(self, root_node_id)
Returns  a dictionary with predecessors as keys and depth as values to go from this node to the root node identified as "root_node_id"
has_partner(self, partner_node_id)
Returns None it the partner does not exist. 1 Otherwise
hide(self)
Hides the node and all edges associated with it
is_expanded(self)
returns [None, None] if it is not a node coming from an expansion
 
otherwise returns [node id that generated this node, type of expansion that generated this node]
is_hidden(self)
if node is hidden, returns 1
if node is not hidden returns 0
is_original(self)
returns 1 if this is a original node (added in the first round of the graph creation)
0 otherwise
 
this method is only used by the clustering...
is_root(self)
Returns 1 if it is a root node (node that was used to build graph
merge_attribute(self, attribute_object, ignore_ids=0)
Merges current attribute with attribute_object passed as argument
 
Since GraphNode does not know the specific details of its attributes, this method just calls
the method merge_attribute of the current attribute
 
ignore_ids=1 merges attributes regardless of their ids
merge_nodes(self, node_object, ignore_ids=0)
merges current node with node_object passed as argument, as well as their attributes
 
ignore_ids=1 merges attributes regardless of their ids
set_as_expanded(self, expanded_from, expansion_type)
Sets the node as a result from an expansion
 
expanded_from is the node_id that originated this expanded node
expansion_type is the expansion name that originated this expanded node
set_as_root(self)
Sets the node as one of the root nodes.
set_attribute(self, attribute_object)
Sets the GraphNodeAttribute "attribute_object" object to current node.
Attribute must be an GraphNodeAttribute object.
set_level(self, level)
Sets the node as one of the root nodes.
set_node_id(self, new_node_id=None)
changes current nodeID for new_node_id
unhide(self)
Unhides the node.

 
Data
        verbose = 0
verbose_has_edge = 0