Package mrv :: Module util :: Class DAGTree
[hide private]
[frames] | no frames]

Class DAGTree

source code

                  object --+        
                           |        
networkx.classes.graph.Graph --+    
                               |    
networkx.classes.digraph.DiGraph --+
                                   |
                                  DAGTree

Adds utility functions to DirectedTree allowing to handle a directed tree like a dag :note: currently this tree does not support instancing :todo: add instancing support
Instance Methods [hide private]
 
children(self, n)
Returns: list of children of given node n
source code
 
children_iter(self, n)
Returns: iterator with children of given node n
source code
 
get_root(self, startnode=None)
Returns: the root node of this dag tree
source code
 
parent(self, n)
Returns: parent of node n
source code
 
parent_iter(self, n)
Returns: iterator returning all parents of node n
source code
 
to_hierarchy_file(self, root, output_path)
Write ourselves in hierarchy file format to the given output_path.
source code

Inherited from networkx.classes.digraph.DiGraph: __init__, add_edge, add_edges_from, add_node, add_nodes_from, clear, degree_iter, edges_iter, has_predecessor, has_successor, in_degree, in_degree_iter, in_edges, in_edges_iter, is_directed, is_multigraph, neighbors, neighbors_iter, out_degree, out_degree_iter, out_edges, out_edges_iter, predecessors, predecessors_iter, remove_edge, remove_edges_from, remove_node, remove_nodes_from, reverse, subgraph, successors, successors_iter, to_directed, to_undirected

Inherited from networkx.classes.graph.Graph: __contains__, __getitem__, __iter__, __len__, __str__, add_cycle, add_path, add_star, add_weighted_edges_from, adjacency_iter, adjacency_list, copy, degree, edges, get_edge_data, has_edge, has_node, nbunch_iter, nodes, nodes_iter, nodes_with_selfloops, number_of_edges, number_of_nodes, number_of_selfloops, order, selfloop_edges, size

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

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

children(self, n)

source code 
Returns:
list of children of given node n

children_iter(self, n)

source code 
Returns:
iterator with children of given node n

get_root(self, startnode=None)

source code 
Parameters:
  • startnode - if None, the first node will be used to get the root from (good for single rooted dags), otherwise this node will be used to get the root from - thus it must exist in the dag tree
Returns:
the root node of this dag tree

parent(self, n)

source code 
Returns:
parent of node n

Note: currently there is only one parent, as instancing is not supported yet

parent_iter(self, n)

source code 
Returns:
iterator returning all parents of node n

to_hierarchy_file(self, root, output_path)

source code 
Write ourselves in hierarchy file format to the given output_path.
Parameters:
  • root - The root of the written file, nodes above it will not be serialized.
Raises:
  • ValueError - If an node's string representation contains a newline or starts with a tab
Notes:
  • Directories are expected to exist
  • works best with strings as nodes, which may not contain newlines