Skip to content

mermaid_relationship

mermaid_relationship

MermaidRelationship — represents a relationship between two Mermaid nodes.

MermaidRelationship dataclass

MermaidRelationship(
    from_node: MermaidNode,
    to_node: MermaidNode,
    type: str = "DEPENDS_ON",
)

Represents a relationship between two nodes in a Mermaid diagram.

to_string

to_string(
    use_alias: bool = False, indentation: int = 4
) -> str

Render the relationship as a Mermaid arrow with type label.

All relationships render as A -->|TYPE| B including DEPENDS_ON.

Source code in src/crew_dcs/integrations/graphs/mermaid/mermaid_relationship.py
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
def to_string(self, use_alias: bool = False, indentation: int = 4) -> str:
    """Render the relationship as a Mermaid arrow with type label.

    All relationships render as ``A -->|TYPE| B`` including DEPENDS_ON.
    """
    if use_alias and self.from_node.alias:
        from_id = self.from_node.alias
    else:
        from_id = f"{self.from_node.type}_{self.from_node.id}".replace(
            "-", "_"
        ).replace(" ", "_")[:50]

    if use_alias and self.to_node.alias:
        to_id = self.to_node.alias
    else:
        to_id = f"{self.to_node.type}_{self.to_node.id}".replace("-", "_").replace(
            " ", "_"
        )[:50]

    rel_type = self.type or "DEPENDS_ON"
    return f"{' ' * indentation}{from_id} -->|{rel_type}| {to_id}"