straph.EulerTourForest package¶
Submodules¶
straph.etf.ChainedTreap module¶
-
class
straph.etf.ChainedTreap.
CTreapNode
(data=None, parent=None, pred=None, suc=None, size=None, left=None, right=None)[source]¶ Bases:
object
A node of a Treap (priority is determined at random and used to balance the Treap)
-
left_rotation
()[source]¶ Perform a left rotation on the Treap with the current TreapNode as the root https://en.wikipedia.org/wiki/Tree_rotation Note : This doesn’t change the cyclic order, successor and predecessor unchanged
- Returns
New root (aka the right child)
-
right_rotation
()[source]¶ Perform a right rotation on the Treap with the current TreapNode as the root https://en.wikipedia.org/wiki/Tree_rotation Note : This doesn’t change the cyclic order, successor and predecessor unchanged
- Returns
New root ( aka the left child)
-
property
tree_number
¶
-
straph.etf.EulerTourForest module¶
-
class
straph.etf.EulerTourForest.
ETFCollections
[source]¶ Bases:
object
Collection of Spanning Euler Forest (1 for each level of the algorithm)
-
class
straph.etf.EulerTourForest.
EulerTourForest
(trees=None, tree_edge_2_node=None, non_tree_edges_al=None)[source]¶ Bases:
object
Custom Data Structure Consisting in a Forest of Euler Tour Trees In the same manner as a Spanning Forest if composed of Spanning Trees
-
add_edge_to_tree
(E, present_node, node_to_add)[source]¶ We assume that present_node is in E and we just add node_to_add.
- Parameters
-
E –
present_node –
node_to_add –
- Returns
-
check_edge_endpoints
(e)[source]¶ Check if one of the endpoints is present in the forest
- Parameters
e –
- Returns
-
check_edge_presence
(e)[source]¶ Check if the edge is in the current spanning forest
- Parameters
e –
- Returns
-
insert_edge
(l, SCC=None, format='cluster', exception=False, streaming_output=None)[source]¶ Insert an edge in the Euler Tour Forest
- Parameters
-
l –
SCC –
format –
exception –
streaming_output –
- Returns
-
is_tree_edge
(e)[source]¶ Return True if e is a tree edge, False otherwise
- Parameters
e – an edge
- Returns
-
link_euler_tour_trees
(E1, E2, e)[source]¶ Merge two euler tour tree
- Parameters
-
E1 – An euler tour tree
E2 – An euler tour tree
e – An edge
- Returns
-
plot
(title=None)[source]¶ Plot the Euler Tour Trees in the Euler Tour Forest
- Parameters
title – An optional title
- Returns
-
remove_edge
(l, SCC=None, format='cluster', exception=False, streaming_output=None)[source]¶ Remove an edge from the Euler Tour Forest
- Parameters
-
l –
SCC –
format –
exception –
streaming_output –
- Returns
-
-
straph.etf.EulerTourForest.
add_to_scc
(T, SCC, format='streaming', exception=False, streaming_output=None)[source]¶ Add the current tree T (aka a connected component) to SCC
- Parameters
-
format –
exception –
streaming_output –
T – An Euler Tour Tree
SCC – list of Strongly Connected Components
- Returns
Updated SCC
-
straph.etf.EulerTourForest.
construct_euler_tour_forest
(edge_list)[source]¶ Construct an Euler Tour Forest from an edge list (the initial graph may be disconnected).
- Parameters
edge_list –
- Returns
straph.etf.EulerTourTree module¶
-
class
straph.etf.EulerTourTree.
EulerTourTree
(root=None, first=None, last=None, weight=None, begin_time=None, end_time=None)[source]¶ Bases:
object
https://en.wikipedia.org/wiki/Euler_tour_technique
-
balance_down
()[source]¶ Balance the Treap to respect the Heap invariant, from root to leaves (full browsing)
- Returns
-
check_heap_invariant
()[source]¶ Check the heap invariant of the Treap
- Returns
True if invariant respected, False otherwise
-
cut
(nodes)[source]¶ Remove and edge from the Euler Tour Tree. [first,…,node_0,after_node_0,….,node_1,after_node_1,…,last] -> [first,…,before_node_0,node_0] [after_node_0,…,node_1,last] -> [first,…,before_node_0] [after_node_0,…,before_node_1] [after_node_1,…,last] -> [first,…,before_node_0,after_node_1,…,last] [after_node_0,before_node_1]
- Parameters
nodes –
- Returns
-
split
(where)[source]¶ Split the Euler Tour Tree according to the split in its Euler Tour. [first,…,where,after_where,…,last] -> [first,…,where] [after_where,…last] Note : The left subtree contains at least the node where whereas the right subtree can be empty.
- Parameters
where – The split is effectuated just after where
- Returns
Left subtree and Right subtree
-
-
straph.etf.EulerTourTree.
construct_euler_tour_tree
(edge_list)[source]¶ Construct an Euler Tour Tree from an edge list
- Parameters
edge_list – An edge list
- Returns
An euler tour tree
-
straph.etf.EulerTourTree.
euler_tour_from_edge_list
(edge_list)[source]¶ Compute the euler tour of a graph ( with edges, including self loops, instead of nodes). https://en.wikipedia.org/wiki/Euler_tour_technique
- Parameters
edge_list – An edge list.
- Returns
A list containing the euler tour.