Quick Start

Learn how to use KeçeciLayout in under 5 minutes.

1. Import Required Libraries

import networkx as nx
import matplotlib.pyplot as plt
import kececilayout as kl

2. Create a Graph

Let’s create a simple path graph:

G = nx.path_graph(8)  # 8-node linear graph

3. Apply Keçeci Layout

pos = kl.kececi_layout(
    G,
    primary_spacing=1.5,
    secondary_spacing=0.8,
    primary_direction='top_down',
    secondary_start='right',
    expanding=True
)
  • primary_spacing: Distance between nodes along the primary axis.

  • secondary_spacing: Base offset for the zigzag.

  • primary_direction: Main direction (top_down, bottom_up, etc.).

  • secondary_start: Zigzag starts to right or left.

  • expanding=True: Zigzag amplitude increases with distance.

4. Visualize the Graph

plt.figure(figsize=(6, 10))
nx.draw(
    G,
    pos=pos,
    with_labels=True,
    node_color='lightcoral',
    node_size=600,
    font_size=12,
    edge_color='gray',
    arrows=True,  # for FancyArrowPatch
    connectionstyle='arc3,rad=0.1'
)
plt.title("8-Node Path Graph with KeçeciLayout")
plt.axis('equal')
plt.show()
KeçeciLayout Example

5. Use with Other Libraries

KeçeciLayout supports multiple graph backends:

Tip

For more examples, check the examples/ folder or try live with Binder.