Skip to content

Task 3: Implement custom bidirectional edge rendering#80

Open
Gauhar-1 wants to merge 2 commits intorayvego:task-3-bidirectional-edgesfrom
Gauhar-1:task-3-bidirectional-edges
Open

Task 3: Implement custom bidirectional edge rendering#80
Gauhar-1 wants to merge 2 commits intorayvego:task-3-bidirectional-edgesfrom
Gauhar-1:task-3-bidirectional-edges

Conversation

@Gauhar-1
Copy link
Copy Markdown

@Gauhar-1 Gauhar-1 commented Oct 17, 2025

Task 3

Problem: The initial graph rendering caused bidirectional edges between two nodes to overlap. This made their labels unreadable and the connections unclear.

Solution: This PR introduces a custom React Flow edge component that completely resolves the rendering issue. The solution is implemented as follows:

  Bidirectional Pair Detection: Implemented logic in the ReactFlowService to automatically detect pairs of edges that connect the same two nodes in opposite directions.

  Custom Edge Component (BidirectionalEdge.tsx): Created a new, dedicated component to handle the rendering for these specific edges.

  Dynamic Path Offsetting: The component uses a direction flag (1 or -1) to calculate a geometric offset, rendering two distinct, parallel Bezier curves instead of a single overlapping one.

  Precise Label Placement: The label for each edge is now positioned exactly halfway between the source node and the peak of its curve. This places the label on the first half of the edge path, ensuring it is always clearly visible and does not overlap with other elements.

All constraints from the task description have been met: the edge type remains curved, labels are always visible, and they stay perfectly aligned when nodes are moved.

Visuals:

Before:

502175354-e7888c79-4ba3-45cc-8bf0-d2b0590ce7ed

After:
Create Next App and 6 more pages - Personal - Microsoft​ Edge 10_17_2025 7_58_16 PM

Task 4

## Task 4: Hierarchical Graph Arrangement Algorithm

This section details the implementation of a hierarchical layout algorithm to create a clear and intuitive visualization for the codebase graph.

Deliverable 1: A function/service that arranges the graph (core/graph-format.service.ts)

  • Algorithm: The service uses the Dagre.js library to calculate a top-down (rankdir: 'TB') hierarchical layout.
  • Custom Logic: I've enabled Dagre's compound feature and used the setParent() function. This creates a true nested structure where child nodes (like GraphNode and C2Subcategory) are mathematically positioned inside their parent containers (C1Output).
  • Clarity: The layout is configured with nodesep and ranksep to ensure the graph is well-spaced and free of congestion. All manual positioning logic has been removed to let the algorithm produce the optimal arrangement.

Deliverable 2: A visualization that makes the codebase structure intuitive (core/react-flow.service.ts)

  • Visual Nesting: The ReactFlowService has been updated to render C1 and C2 nodes with type: 'group'. This draws them as visible "boxes" or containers.
  • Intuitive Design: The final visualization now clearly shows each C1 category in its own box, with its contents physically inside it, fulfilling the core requirement of a clean and easy-to-follow graph.

@Gauhar-1 Gauhar-1 changed the title feature: Implement custom bidirectional edge rendering Task 3: Implement custom bidirectional edge rendering Oct 19, 2025
@Gauhar-1 Gauhar-1 force-pushed the task-3-bidirectional-edges branch from 86800ae to db90856 Compare October 19, 2025 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant