1 from obitools.graph import UndirectedGraph,Node
2 from obitools.graph.algorithms.component import componentCount
3
4
6
7
8 - def getNode(self,node=None,index=None):
12
13 - def addEdge(self,node1=None,node2=None,index1=None,index2=None,**data):
14 index1=self.addNode(node1, index1)
15 index2=self.addNode(node2, index2)
16
17 cc = set(n.index for n in self.getNode(index=index2).componentIterator())
18
19 assert index1 in self._node[index2] or index1 not in cc, \
20 "No more than one path is alloed between two nodes in a tree"
21
22 UndirectedGraph.addEdge(self, index1=index1, index2=index2,**data)
23
24 return (index1,index2)
25
28
30
32 for c in self:
33 yield c
34 for cc in c:
35 yield cc
36