給定一個2D點(#pts x 2)的數組和一個點的數組連接到哪個(#bonds x 2 int數組,索引爲pts),我怎樣纔能有效地返回由債券形成的多邊形排列?來自連接點網絡的多邊形
可能會有'懸掛'鍵(如下圖左上角)不關閉多邊形,這些應該被忽略。
import numpy as np
xy = np.array([[2.72,-2.976], [2.182,-3.40207],
[-3.923,-3.463], [2.1130,4.5460], [2.3024,3.4900], [.96979,-.368],
[-2.632,3.7555], [-.5086,.06170], [.23409,-.6588], [.20225,-.9540],
[-.5267,-1.981], [-2.190,1.4710], [-4.341,3.2331], [-3.318,3.2654],
[.58510,4.1406], [.74331,2.9556], [.39622,3.6160], [-.8943,1.0643],
[-1.624,1.5259], [-1.414,3.5908], [-1.321,3.6770], [1.6148,1.0070],
[.76172,2.4627], [.76935,2.4838], [3.0322,-2.124], [1.9273,-.5527],
[-2.350,-.8412], [-3.053,-2.697], [-1.945,-2.795], [-1.905,-2.767],
[-1.904,-2.765], [-3.546,1.3208], [-2.513,1.3117], [-2.953,-.5855],
[-4.368,-.9650]])
BL= np.array([[22,23], [28,29], [8,9],
[12,31], [18,19], [31,32], [3,14],
[32,33], [24,25], [10,30], [15,23],
[5,25], [12,13], [0,24], [27,28],
[15,16], [5,8], [0,1], [11,18],
[2,27], [11,13], [33,34], [26,33],
[29,30], [7,17], [9,10], [26,30],
[17,22], [5,21], [19,20], [17,18],
[14,16], [7,26], [21,22], [3,4],
[4,15], [11,32], [6,19], [6,13],
[16,20], [27,34], [7,8], [1,9]])
你想要的的Voronoi圖(Tesselation的)也有在這個網站的例子不勝枚舉http://stackoverflow.com/questions/10650645/python-calculate-voronoi-tesselation-from-scipys-delaunay-triangulation -in-3d及其實現可以使用Fortune的算法在純python中獲得,或者藉助在github和別處找到的其他代碼樣本獲得。 – 2016-02-19 17:45:54
不,Dan,這不是我所追求的。我已經有了一個tesselation,但是我的tesselations通常不與任何voronoi圖相關,因爲它們不是三角形的對偶。我上面的例子是通過voronoi完成的,但這在我的應用程序中並不普遍。 – NPMitchell
這些可以幫助:http://cstheory.stackexchange.com/questions/3447/for-a-planar-graph-find-the-algorithm-that-constructs-a-cycle-basis-with-each?rq=1 ,http://cstheory.stackexchange.com/questions/27586/finding-outer-face-in-plane-graph-embedded-planar-graph – liborm