Split Strands Graph#
Graph#
- class SplitStrandsGraph#
Graph containing only one DNA strand.
For this graph \(G = (V, E)\) we have:
\(\forall v \in V, \bar{v} \notin V\)
\(\forall e \in E, \bar{e} \notin E\)
Methods:
attr
(attrname)Return the value associated to attribute attrname.
attrs
()Return the dictionnary of all attributes.
edges
()Return the edge container.
set_attr
(attrname, attrvalue)Change the value of the attributes else create them.
vertices
()Return the vertices container.
- attr(attrname)#
Return the value associated to attribute attrname.
- Parameters:
attrname (
str
) – Attribute’s name- Returns:
Attribute value corresponding to the attribute name
- Return type:
- Raises:
NoGraphAttribute – When there is no attribute key
- attrs()#
Return the dictionnary of all attributes.
- Returns:
Dictionnary of attribute name as key and their value
- Return type:
- edges()#
Return the edge container.
- Returns:
Edges container
- Return type:
- set_attr(attrname, attrvalue)#
Change the value of the attributes else create them.
- vertices()#
Return the vertices container.
- Returns:
Vertices container
- Return type:
Vertices Container#
- class SplitStrandsVertices#
Unique oriented vertices container.
This vertices container is containing only one orientation for each of its vertex i.e. \(\forall v \in V, \bar{v} \notin V\)
Warning
You must not call this class. Use it only for typing or get an already existing object.
Methods:
__contains__
(vertex)Answer if vertex is in vertices container.
__iter__
()Iterate on oriented vertices.
__len__
()Return the number of oriented vertices.
add
(orientation)Add the vertex to the connected component record.
attr
(vertex_index, attrname)Return the value associated to vertex attribute attrname.
attrs
(vertex_index)Iterate over all vertex's attributes.
contains_indor
(vertex)Answer if oriented vertex in vertices container.
delete
(vertex_index)Remove vertex from vertices container.
delete_several
(vertex_indices)Remove vertices from vertices container.
new_attr
(attrname, default)Add an attribute entry.
orientation
(vertex_index)Return the orientation of vertex's index.
set_attr
(vertex_index, attrname, attrvalue)Change the value of the attributes else create them.
- __contains__(vertex)#
Answer if vertex is in vertices container.
- Returns:
Vertex is in vertices container
- Return type:
- add(orientation)#
Add the vertex to the connected component record.
- attr(vertex_index, attrname)#
Return the value associated to vertex attribute attrname.
- Parameters:
- Returns:
Attribute value corresponding to the attribute name
- Return type:
- Raises:
NoVertexIndex – If vertex does not exist
NoVerticesAttribute – If there is no attribute nammed like this for vertices
- attrs(vertex_index)#
Iterate over all vertex’s attributes.
- Parameters:
vertex_index (
IndexT
) – Vertex’s index- Yields:
- Raises:
NoVertexIndex – If there is no vertex index
- contains_indor(vertex)#
Answer if oriented vertex in vertices container.
- delete(vertex_index)#
Remove vertex from vertices container.
- Parameters:
vertex_index (
IndexT
) – Vertex to delete- Raises:
NoVertexIndex – If vertex does not exist
Warning
This operation may invalidate vertex indices. In fact, deleting one vertex implies shifting all next indices. Because of this, keys should always be removed in decreasing index order:
>>> for vertex in sorted(vertices_to_del, reverse=True): >>> graph.vertices().delete(vertex)
Note
All next vertex indices are decreased in edges they belong. But concerning edge indices are not.
- delete_several(vertex_indices)#
Remove vertices from vertices container.
- Parameters:
vertex_indices (
iterable
ofIndexT
) – Vertices to delete- Raises:
NoVertexIndex – If one vertex does not exist
Warning
This operation may invalidate vertex indices. In fact, deleting one vertex implies shifting all next indices.
Notes
At the oposite of
delete()
method, it is not necessary to sort vertex_indices. This is done internally.All next vertex indices are decreased in edges they belong. But concerning edge indices are not.
- new_attr(attrname, default)#
Add an attribute entry.
Note
Before setting attribute to one vertex, it is necessary to add an attribute entry using this method.
- orientation(vertex_index)#
Return the orientation of vertex’s index.
- Parameters:
vertex_index (
IndexT
) – Vertex’s index- Returns:
Vertex’s index orientation
- Return type:
- Raises:
NoVertexIndex – If there is no vertex index
- set_attr(vertex_index, attrname, attrvalue)#
Change the value of the attributes else create them.
- Parameters:
- Raises:
NoVerticesAttribute – If there is no attribute nammed like this for vertices
WrongAttributeType – Given value does not correspond to attribute’s type
NoVertexIndex – If there is no vertex index
Note
Be sure having added an attribute entry using the method
new_attr()
Edges Container#
- class SplitStrandsEdges#
Unique oriented edges container.
This edges container is containing only one orientation for each of its edge i.e. \(\forall e \in E, \bar{e} \notin E\)
Warning
You must not instantiate a Edges object. Use it only for typing or get an already instanciated object.
Methods:
__contains__
(edge)Return True if the indices edge is in edges container.
__iter__
()Iterate over indices edges with edge index.
__len__
()Return the number of edges.
add
(first_vertex, second_vertex)Add edge to edges.
attr
(edge_index, attrname)Return the edge attribute attrname.
attrs
(edge_index)Iterate over all edge's attributes.
delete
(first_vertex, second_vertex, edge_index)Remove the edge.
eindor_to_eind
(first_vertex, second_vertex)Iterate over edge index from indices edge.
neighbours
(vertex)Iterate over vertex's adjacencies vertices.
new_attr
(attrname, default)Add an attribute entry.
preds
(vertex)Iterate over vertex's predecessors.
set_attr
(edge_index, attrname, attrvalue)Change the value of one attribute.
succs
(vertex)Iterate over vertex's successors.
- __contains__(edge)#
Return True if the indices edge is in edges container.
- Parameters:
edge (
EIndT
) – Indices edge- Returns:
Indices edge in edges container
- Return type:
- __iter__()#
Iterate over indices edges with edge index.
- Yields:
EIndIndT
– Indices edges with their edge index
- __len__()#
Return the number of edges.
- Returns:
Number of edges
- Return type:
Notes
\(\forall e \in E, \bar{e} \notin E\)
- add(first_vertex, second_vertex)#
Add edge to edges.
- Parameters:
- Returns:
Edge index
- Return type:
- Raises:
NoVertexIndex – If one vertex does not exist
- attr(edge_index, attrname)#
Return the edge attribute attrname.
- Parameters:
- Returns:
Attribute value
- Return type:
- Raises:
NoEdgeIndex – If edge does not exist
NoEdgesAttribute – If there is no attribute name like this for edges
Note
A removed edge still have a recorded attribute.
- attrs(edge_index)#
Iterate over all edge’s attributes.
- Parameters:
edge_index (
IndexT
) – Edge’s index- Yields:
- Raises:
NoEdgeIndex – If there is no edge index
Note
A removed edge still have a recorded attribute.
- delete(first_vertex, second_vertex, edge_index)#
Remove the edge.
- Parameters:
- Raises:
NoVertexIndex – If vertex does not exist
NoIndicesEdge – If there is no recorded edge with these vertices and this index
Note
When deleting, the edge is replacing by the last one in adjancy list, and the last element of the adjancy list is removed.
- eindor_to_eind(first_vertex, second_vertex)#
Iterate over edge index from indices edge.
- Parameters:
- Yields:
IndexT
– Edge index- Raises:
NoVertexIndex – One of the vertex in edge does not exist
- neighbours(vertex)#
Iterate over vertex’s adjacencies vertices.
- Parameters:
vertex (
IndexT
) – Vertex’s index- Yields:
IndIndT
– Adjacent vertices’s index with edge index- Raises:
NoVertexIndex – If vertex does not exist
- new_attr(attrname, default)#
Add an attribute entry.
Note
Before setting attribute to one edge, it is necessary to add an attribute entry using this method.
- preds(vertex)#
Iterate over vertex’s predecessors.
- Parameters:
vertex (
IndexT
) – Vertex’s index- Yields:
IndIndT
– Predecessor vertex’s index with edge index- Raises:
NoVertexIndex – If vertex does not exist
- set_attr(edge_index, attrname, attrvalue)#
Change the value of one attribute.
- Parameters:
- Raises:
NoEdgesAttribute – If there is no attribute nammed like this for edges
WrongAttributeType – Given value does not correspond to attribute’s type
NoEdgeIndex – If there is no vertex index
Note
Be sure having added an attribute entry using the method
new_attr()
- succs(vertex)#
Iterate over vertex’s successors.
- Parameters:
vertex (
IndexT
) – Vertex’s index- Yields:
IndIndT
– Successors vertex’s index with edge index- Raises:
NoVertexIndex – If vertex does not exist