Package obitools :: Package graph :: Class Node
[hide private]
[frames] | no frames]

Class Node

source code


Instance Methods [hide private]
 
__init__(self, index, graph)
Constructor on Node instance.
source code
obitools.graph.Graph
getGraph(self)
return graph owning this node.
source code
 
getLabel(self)
return label associated to this node.
source code
bool
has_key(self, key)
test is the node instance has a property named 'key'.
source code
iterator on Node instances
neighbourIterator(self, nodePredicat=None, edgePredicat=None)
iterate through the nodes directly connected to this node.
source code
set of int
neighbourIndexSet(self)
Return a set of node indexes directely connected to this node.
source code
iterator on int
neighbourIndexIterator(self, nodePredicat=None, edgePredicat=None)
iterate through the node indexes directly connected to this node.
source code
int
degree(self, nodeIndexes=None)
return count of edges linking this node to the set of nodes describes by their index in nodeIndexes
source code
set of int
componentIndexSet(self, nodePredicat=None, edgePredicat=None)
Return the set of node index in the same connected component.
source code
iterator on Node instance
componentIterator(self, nodePredicat=None, edgePredicat=None)
Iterate through the nodes in the same connected component.
source code
iterator on list of int
shortestPathIterator(self, nodes=None)
Iterate through the shortest path sourcing from this node.
source code
list of int or None
shortestPathTo(self, node=None, index=None)
return one of the shortest path linking this node to specified node.
source code
 
__getitem__(self, key)
return the value of the <key> property of this node
source code
 
__setitem__(self, key, value)
set the value of a node property.
source code
int
__len__(self)
Count neighbour of this node
source code
iterator in Node instances
__iter__(self)
iterate through neighbour of this node
source code
 
__contains__(self, key) source code
 
__str__(self)
str(x)
source code

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

Properties [hide private]
  label
Label of the node
  graph
Graph owning this node

Inherited from object: __class__

Method Details [hide private]

__init__(self, index, graph)
(Constructor)

source code 

Constructor on Node instance.

Normaly this constructor is only used by Graph methods.

Parameters:
  • index (int) - Index of the node in the graph
  • graph (obitools.graph.Graph) - graph instance owning the node
Overrides: object.__init__

has_key(self, key)

source code 

test is the node instance has a property named 'key'.

Parameters:
  • key (str) - the name of a property
Returns: bool
True if the nade has a property named <key>

neighbourIterator(self, nodePredicat=None, edgePredicat=None)

source code 

iterate through the nodes directly connected to this node.

Parameters:
  • nodePredicat (function) - a function accepting one node as parameter and returning True if this node must be returned by the iterator.
  • edgePredicat (function) - a function accepting one edge as parameter and returning True if the edge linking self and the current must be considered.
Returns: iterator on Node instances

neighbourIndexSet(self)

source code 

Return a set of node indexes directely connected to this node.

Returns: set of int

Attention: do not change this set unless you know exactly what you do.

neighbourIndexIterator(self, nodePredicat=None, edgePredicat=None)

source code 

iterate through the node indexes directly connected to this node.

Parameters:
  • nodePredicat (function) - a function accepting one node as parameter and returning True if this node must be returned by the iterator.
  • edgePredicat (function) - a function accepting one edge as parameter and returning True if the edge linking self and the current must be considered.
Returns: iterator on int

degree(self, nodeIndexes=None)

source code 

return count of edges linking this node to the set of nodes describes by their index in nodeIndexes

Parameters:
  • nodeIndexes (set of int) - set of node indexes. if set to None, all nodes of the graph are take into account. Set to None by default.
Returns: int

componentIndexSet(self, nodePredicat=None, edgePredicat=None)

source code 

Return the set of node index in the same connected component.

Parameters:
  • nodePredicat (function) - a function accepting one node as parameter and returning True if this node must be returned by the iterator.
  • edgePredicat (function) - a function accepting one edge as parameter and returning True if the edge linking self and the current must be considered.
Returns: set of int

shortestPathIterator(self, nodes=None)

source code 

Iterate through the shortest path sourcing from this node. if nodes is not None, iterates only path linkink this node to one node listed in nodes

Parameters:
  • nodes (iterable on int) - set of node index
Returns: iterator on list of int
an iterator on list of int describing path

shortestPathTo(self, node=None, index=None)

source code 

return one of the shortest path linking this node to specified node.

Parameters:
  • node - a node label or None
  • index (int) - a node index or None. the parameter index has a priority on the parameter node.
Returns: list of int or None
list of node index corresponding to the path or None if no path exists.

__getitem__(self, key)
(Indexing operator)

source code 

return the value of the <key> property of this node

Parameters:
  • key (str) - the name of a property

__setitem__(self, key, value)
(Index assignment operator)

source code 

set the value of a node property. In the property doesn't already exist a new property is added to this node.

Parameters:
  • key (str) - the name of a property
  • value - the value of the property

See Also: Node.__getitem__

__len__(self)
(Length operator)

source code 

Count neighbour of this node

Returns: int

See Also: Node.degree

__iter__(self)

source code 

iterate through neighbour of this node

Returns: iterator in Node instances

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

Property Details [hide private]

label

Label of the node

Get Method:
getLabel(self) - return label associated to this node.

graph

Graph owning this node

Get Method:
getGraph(self) - return graph owning this node.