KececiLayout
Kececi Layout (Keçeci Yerleşimi): A deterministic graph layout algorithm designed for visualizing linear or sequential structures with a characteristic "zig-zag" or "serpentine" pattern.
Python implementation of the Keçeci layout algorithm for graph visualization. Description / Açıklama
This algorithm arranges nodes sequentially along a primary axis and offsets them alternately along a secondary axis. It's particularly useful for path graphs, chains, or showing progression.
Bu algoritma, düğümleri birincil eksen boyunca sıralı olarak yerleştirir ve ikincil eksen boyunca dönüşümlü olarak kaydırır. Yol grafları, zincirler veya ilerlemeyi göstermek için özellikle kullanışlıdır. English Description
Keçeci Layout:
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.
Key Characteristics:
Linear Focus: Particularly useful for visualizing linear or sequential structures, such as paths, chains, or ordered processes.
Deterministic: Produces the exact same layout for the same graph and parameters every time.
Overlap Reduction: Helps prevent node collisions by spreading nodes out away from the primary axis.
Parametric: Can be customized using parameters such as the primary direction (e.g., top-down), the starting side for the secondary offset (e.g., start_right), and the spacing along both axes (primary_spacing, secondary_spacing).
Türkçe Tanımlama
Keçeci Yerleşimi (Keçeci Layout):
Graf görselleştirmede kullanılan deterministik bir düğüm yerleştirme algoritmasıdır. Bu yöntemde düğümler, belirlenen birincil (ana) eksen boyunca sıralı olarak yerleştirilir. Her bir sonraki düğüm, ana eksenin bir sağına bir soluna (veya bir üstüne bir altına) olmak üzere, ikincil eksen doğrultusunda dönüşümlü olarak kaydırılır. Genellikle, ana eksende ilerledikçe ikincil eksendeki kaydırma miktarı artar ve bu da karakteristik bir "zıgzag" veya "yılanvari" desen oluşturur.
Temel Özellikleri:
Doğrusal Odak: Özellikle yollar (paths), zincirler veya sıralı süreçler gibi doğrusal veya ardışık yapıları görselleştirmek için kullanışlıdır.
Deterministik: Aynı graf ve parametrelerle her zaman aynı sonucu üretir.
Çakışmayı Azaltma: Düğümleri ana eksenden uzağa yayarak çakışmaları önlemeye yardımcı olur.
Parametrik: Ana eksenin yönü (örn. top-down), ikincil kaydırmanın başlangıç yönü (örn. start_right) ve eksenler arası boşluklar (primary_spacing, secondary_spacing) gibi parametrelerle özelleştirilebilir.
Installation / Kurulum
conda install bilgi::kececilayout -y
pip install kececilayout
https://anaconda.org/bilgi/kececilayout
https://pypi.org/project/KececiLayout/
https://github.com/WhiteSymmetry/kececilayout
https://zenodo.org/records/15313947
https://zenodo.org/records/15314329 Usage / Kullanım
The layout function generally accepts a graph object and returns positions. Example with NetworkX
import networkx as nx import matplotlib.pyplot as plt import kececilayout as kl # Assuming the main function is imported like this import random
#Create a graph G = nx.path_graph(10)
#Calculate layout positions using the generic function #(Assuming kl.kececi_layout_v4 is the main/generic function) pos = kl.kececi_layout_v4(G, primary_spacing=1.0, secondary_spacing=0.5, primary_direction='top-down', secondary_start='right')
#Draw the graph plt.figure(figsize=(6, 8)) nx.draw(G, pos=pos, with_labels=True, node_color='skyblue', node_size=500, font_size=10) plt.title("Keçeci Layout with NetworkX") plt.axis('equal') # Ensure aspect ratio is equal plt.show()
import matplotlib.pyplot as plt import math import networkx as nx import kececilayout as kl import random
try: import kececilayout as kl except ImportError: print("Error: 'kececi_layout.py' not found or could not be imported.") print("Please ensure the file containing kececi_layout_v4 is accessible.") exit()
#--- General Layout Parameters --- LAYOUT_PARAMS = { 'primary_spacing': 1.0, 'secondary_spacing': 0.6, # Make the zigzag noticeable 'primary_direction': 'top-down', 'secondary_start': 'right' } N_NODES = 10 # Number of nodes in the example graph
#=== NetworkX Example === try: import networkx as nx print("\n--- NetworkX Example ---")
#Generate graph (Path graph)
G_nx = nx.path_graph(N_NODES)
print(f"NetworkX graph generated: {G_nx.number_of_nodes()} nodes, {G_nx.number_of_edges()} edges")
#Calculate layout
print("Calculating Keçeci Layout...")
#Call the layout function from the imported module
pos_nx = kl.kececi_layout_v4(G_nx, **LAYOUT_PARAMS)
#print("NetworkX positions:", pos_nx) # Debug print if needed
#Plot
plt.figure(figsize=(6, 8)) # Suitable figure size for vertical layout
nx.draw(G_nx, # NetworkX graph object
pos=pos_nx, # Positions calculated by Kececi Layout
with_labels=True, # Show node labels (indices)
node_color='skyblue',# Node color
node_size=700, # Node size
font_size=10, # Label font size
edge_color='gray') # Edge color
plt.title(f"NetworkX ({N_NODES} Nodes) with Keçeci Layout") # Plot title
plt.xlabel("X Coordinate") # X-axis label
plt.ylabel("Y Coordinate") # Y-axis label
plt.axis('equal') # Ensure equal aspect ratio for correct spacing perception
#plt.grid(False) # Ensure grid is off
plt.show() # Display the plot
except ImportError: print("NetworkX is not installed. Skipping this example.") except Exception as e: print(f"An error occurred in the NetworkX example: {e}") import traceback traceback.print_exc()
print("\n--- NetworkX Example Finished ---")

Creator
Submitter
Views: 20 Downloads: 0
Created: 24th Jun 2025 at 18:38

This item has not yet been tagged.

None
Version History
Version 1 (earliest) Created 24th Jun 2025 at 18:38 by Mehmet Keçeci
No revision comments