From 1ae6fbe08f10ec5e8ad4adafc545d8fc6fefee4c Mon Sep 17 00:00:00 2001 From: David Mayerich Date: Mon, 18 Dec 2017 13:47:06 -0600 Subject: [PATCH] error fixes in network.py and added a bounding box method --- python/network.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/python/network.py b/python/network.py index 7fc7f5b..b14d2b7 100644 --- a/python/network.py +++ b/python/network.py @@ -22,6 +22,9 @@ class Node: self.o = outgoing self.i = incoming +# def p(): +# return self.p + ''' Definition of the Fiber class. Duplicate of the Node class in network @@ -213,7 +216,7 @@ def importNWT(str): edge = readFiber(file) fiberList.append(edge) - exportNWT("/home/pavel/Documents/Python/NetLayout/from_python_seg.nwt", nodeList, fiberList) + #exportNWT("/home/pavel/Documents/Python/NetLayout/from_python_seg.nwt", nodeList, fiberList) print(str) return nodeList, fiberList; @@ -270,11 +273,23 @@ def getCircularLayout(graph, dim, radius): Return the positions dictionary for the Spring layout. ''' def getSpringLayout(graph, pos, iterations, scale): - return nx.spring_layout(graph, 2, None, pos, iterations, weight='weight', scale, None) + return nx.spring_layout(graph, 2, None, pos, iterations, 'weight', scale, None) ''' Draws the graph. ''' def drawGraph(graph, pos): nx.draw(graph, pos) - return \ No newline at end of file + return + +def aabb(nodeList, edgeList): + + lower = nodeList[0].p.copy() + upper = lower.copy() + for i in nodeList: + for c in range(len(lower)): + if lower[c] > i.p[c]: + lower[c] = i.p[c] + if upper[c] < i.p[c]: + upper[c] = i.p[c] + return lower, upper -- libgit2 0.21.4