kececilayout 0.5.1__tar.gz → 0.5.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kececilayout
3
- Version: 0.5.1
3
+ Version: 0.5.2
4
4
  Summary: Çeşitli graf kütüphaneleri için sıralı-zigzag yerleşimleri sağlayan bir Python paketi.
5
5
  Home-page: https://github.com/WhiteSymmetry/kececilayout
6
6
  Author: Mehmet Keçeci
@@ -10,7 +10,7 @@ import inspect
10
10
  import warnings
11
11
 
12
12
  # Paket sürüm numarası
13
- __version__ = "0.5.1"
13
+ __version__ = "0.5.2"
14
14
 
15
15
  # =============================================================================
16
16
  # OTOMATİK İÇE AKTARMA VE __all__ OLUŞTURMA
@@ -62,6 +62,9 @@ from .kececi_layout import ( # Veya fonksiyonların bulunduğu asıl modül
62
62
  _compute_positions,
63
63
  _extract_graph_data,
64
64
  _validate_directions,
65
+ avg_edge_length,
66
+ _segments_intersect,
67
+ count_edge_crossings,
65
68
 
66
69
  # Drawing functions
67
70
  draw_kececi,
@@ -115,6 +118,9 @@ __all__ = [
115
118
  '_compute_positions',
116
119
  '_extract_graph_data',
117
120
  '_validate_directions',
121
+ 'avg_edge_length',
122
+ '_segments_intersect',
123
+ 'count_edge_crossings',
118
124
 
119
125
  # Drawing functions
120
126
  'draw_kececi',
@@ -166,3 +172,4 @@ def old_function_placeholder():
166
172
  # Eğer bu eski fonksiyonu da dışa aktarmak istiyorsanız, __all__ listesine ekleyin
167
173
  # __all__.append('old_function_placeholder')
168
174
 
175
+
@@ -1,6 +1,6 @@
1
1
  # _version.py
2
2
 
3
- __version__ = "0.5.0"
3
+ __version__ = "0.5.2"
4
4
  __license__ = "AGPL3.0-or-later"
5
5
  __description__ = "A deterministic node placement algorithm used in graph visualization. In this layout, nodes are arranged sequentially along a defined primary axis. Each subsequent node is then alternately offset along a secondary, perpendicular axis, typically moving to one side of the primary axis and then the other. Often, the magnitude of this secondary offset increases as nodes progress along the primary axis, creating a characteristic zig-zag or serpentine pattern."
6
6
  __author__ = "Mehmet Keçeci"
@@ -355,6 +355,66 @@ def _compute_positions(nodes: List[Any],
355
355
  pos[node] = (so, pc) if sa == 'x' else (pc, so)
356
356
  return pos
357
357
 
358
+ def count_edge_crossings(pos, edges):
359
+ """Basit ama etkili crossing sayacı: (bounding box kesişimi - yaklaşık) (O(m²))"""
360
+ crossings = 0
361
+ segments = []
362
+
363
+ # Tüm edge'leri segment olarak sakla
364
+ for u, v in edges:
365
+ x1, y1 = pos[u]
366
+ x2, y2 = pos[v]
367
+ segments.append(((x1, y1), (x2, y2)))
368
+
369
+ # Tüm segment çiftlerini kontrol et
370
+ for i in range(len(segments)):
371
+ for j in range(i+1, len(segments)):
372
+ if _segments_intersect(segments[i], segments[j]):
373
+ crossings += 1
374
+ return crossings
375
+
376
+ def _segments_intersect(seg1, seg2):
377
+ """İki doğru parçasının kesişip kesişmediğini kontrol eder (Cohen-Sutherland değil, basit)"""
378
+ (x1, y1), (x2, y2) = seg1
379
+ (x3, y3), (x4, y4) = seg2
380
+
381
+ # Ortak uç noktaları crossing olarak sayma
382
+ if (x1, y1) in [(x3, y3), (x4, y4)] or (x2, y2) in [(x3, y3), (x4, y4)]:
383
+ return False
384
+
385
+ # Yönlendirme fonksiyonu
386
+ def orientation(ax, ay, bx, by, cx, cy):
387
+ val = (by - ay) * (cx - bx) - (bx - ax) * (cy - by)
388
+ if abs(val) < 1e-9: return 0 # colinear
389
+ return 1 if val > 0 else 2 # clockwise / counterclockwise
390
+
391
+ o1 = orientation(x1, y1, x2, y2, x3, y3)
392
+ o2 = orientation(x1, y1, x2, y2, x4, y4)
393
+ o3 = orientation(x3, y3, x4, y4, x1, y1)
394
+ o4 = orientation(x3, y3, x4, y4, x2, y2)
395
+
396
+ # Genel kesişim durumu
397
+ if o1 != o2 and o3 != o4:
398
+ return True
399
+
400
+ return False
401
+
402
+ edges_small = list(G_small.edges())
403
+ cross_basic = count_edge_crossings(pos_basic, edges_small)
404
+ cross_edge_aware = count_edge_crossings(pos_edge_aware, edges_small)
405
+
406
+ def avg_edge_length(pos, edges):
407
+ # Ortalama edge uzunluğu
408
+ total = 0.0
409
+ for u, v in edges:
410
+ x1, y1 = pos[u]
411
+ x2, y2 = pos[v]
412
+ total += math.hypot(x1 - x2, y1 - y2)
413
+ return total / len(edges) if edges else 0
414
+
415
+ avg_len_basic = avg_edge_length(pos_basic, edges_small)
416
+ avg_len_edge_aware = avg_edge_length(pos_edge_aware, edges_small)
417
+
358
418
  # =============================================================================
359
419
  # 1. TEMEL LAYOUT HESAPLAMA FONKSİYONU (2D)
360
420
  # Bu fonksiyon sadece koordinatları hesaplar, çizim yapmaz.
@@ -2187,3 +2247,4 @@ if __name__ == '__main__':
2187
2247
 
2188
2248
 
2189
2249
 
2250
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kececilayout
3
- Version: 0.5.1
3
+ Version: 0.5.2
4
4
  Summary: Çeşitli graf kütüphaneleri için sıralı-zigzag yerleşimleri sağlayan bir Python paketi.
5
5
  Home-page: https://github.com/WhiteSymmetry/kececilayout
6
6
  Author: Mehmet Keçeci
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
6
6
 
7
7
  [project]
8
8
  name = "kececilayout"
9
- version = "0.5.1"
9
+ version = "0.5.2"
10
10
 
11
11
  # Diğer proje bilgileri (isteğe bağlı ama tavsiye edilir)
12
12
  authors = [
@@ -73,3 +73,4 @@ configuration = "docs/conf.py" # Build konfigürasyonu belirtin
73
73
  [project.urls]
74
74
  "Homepage" = "https://github.com/WhiteSymmetry/kececilayout"
75
75
  "Bug Tracker" = "https://github.com/WhiteSymmetry/kececilayout/issues"
76
+
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes