Commit 1ae6fbe08f10ec5e8ad4adafc545d8fc6fefee4c
1 parent
bd78d658
error fixes in network.py and added a bounding box method
Showing
1 changed file
with
18 additions
and
3 deletions
Show diff stats
python/network.py
... | ... | @@ -22,6 +22,9 @@ class Node: |
22 | 22 | self.o = outgoing |
23 | 23 | self.i = incoming |
24 | 24 | |
25 | +# def p(): | |
26 | +# return self.p | |
27 | + | |
25 | 28 | ''' |
26 | 29 | Definition of the Fiber class. |
27 | 30 | Duplicate of the Node class in network |
... | ... | @@ -213,7 +216,7 @@ def importNWT(str): |
213 | 216 | edge = readFiber(file) |
214 | 217 | fiberList.append(edge) |
215 | 218 | |
216 | - exportNWT("/home/pavel/Documents/Python/NetLayout/from_python_seg.nwt", nodeList, fiberList) | |
219 | + #exportNWT("/home/pavel/Documents/Python/NetLayout/from_python_seg.nwt", nodeList, fiberList) | |
217 | 220 | print(str) |
218 | 221 | return nodeList, fiberList; |
219 | 222 | |
... | ... | @@ -270,11 +273,23 @@ def getCircularLayout(graph, dim, radius): |
270 | 273 | Return the positions dictionary for the Spring layout. |
271 | 274 | ''' |
272 | 275 | def getSpringLayout(graph, pos, iterations, scale): |
273 | - return nx.spring_layout(graph, 2, None, pos, iterations, weight='weight', scale, None) | |
276 | + return nx.spring_layout(graph, 2, None, pos, iterations, 'weight', scale, None) | |
274 | 277 | |
275 | 278 | ''' |
276 | 279 | Draws the graph. |
277 | 280 | ''' |
278 | 281 | def drawGraph(graph, pos): |
279 | 282 | nx.draw(graph, pos) |
280 | - return | |
281 | 283 | \ No newline at end of file |
284 | + return | |
285 | + | |
286 | +def aabb(nodeList, edgeList): | |
287 | + | |
288 | + lower = nodeList[0].p.copy() | |
289 | + upper = lower.copy() | |
290 | + for i in nodeList: | |
291 | + for c in range(len(lower)): | |
292 | + if lower[c] > i.p[c]: | |
293 | + lower[c] = i.p[c] | |
294 | + if upper[c] < i.p[c]: | |
295 | + upper[c] = i.p[c] | |
296 | + return lower, upper | ... | ... |