---
agentTools:
  projectIndex: https://makinarocks-link.readme.io/v1.1.0-Kor/llms.txt
---

# create_link_graph

`create_link_graph`는 `components` 및 `edges` 정보를 통하여 DAG 그래프를 생성하는 클래스인 `MRXLinkDagModel`을 생성하는 메소드입니다.

### 그래프 객체 생성

```
create_link_graph(
    components: Optional[List[MRXLinkComponentModel]] = None,
    edges: Optional[List[MRXLinkDagEdgeModel]] = None,
) -> MRXLinkDagModel
```

* **Parameters**
  * `components`(list): `create_link_component` 메소드를 통하여 생성된 component들의 리스트 [(create\_link\_component)](https://makinarocks-link.readme.io/v0.11.0-Kor/reference/create_link_component)
  * `edges`(list): `create_link_edge` 메소드를 통하여 생성된 edge들의 리스트 [(create\_link\_edge)](https://makinarocks-link.readme.io/v0.11.0-Kor/reference/create_link_edge)

* **Returns**
  * `MRXLinkDagModel(nodes=components, edges=edges)`

* **Troubleshooting**
  * *RuntimeError: This component name already exists in the pipeline.*
    * Component ID가 중복되어 입력되었을 경우 발생합니다.
  * *ValueError: Component name is duplicated*
    * Component name이 중복되어 입력되었을 경우 발생합니다.
  * *There is no component corresponding to parent\_id '{parent\_id}'*
    * 입력한 Parent Component ID가 존재하지 않을 때 발생합니다.
  * *There is no component corresponding to child\_id '{child\_id}'*
    * 입력한 Child Component ID가 존재하지 않을 때 발생합니다.

### Example

```Text Python
from mrx_link.sdk.utils import * 

# Code cell
code1 = """
x = 1
"""
code2 = """
y = 2
"""
code3 = """
print(f"{x=}, {y=}")
"""

if __name__ == "__main__":
    # 컴포넌트 생성
    component1 = create_link_component(identifier="111-1", name="test", code=code1)
    component2 = create_link_component(identifier="111-2", name="test2", code=code2)
    component3 = create_link_component(identifier="111-3", name="test3", code=code3)

    # 컴포넌트 간의 연결 관계 생성
    edge1 = create_link_edge(parent_id="111-1", child_id="111-3")
    edge2 = create_link_edge(parent_id="111-2", child_id="111-3")

    # Graph 생성
    graph = create_link_graph(
    components=[component1, component2, component3],
    edges=[edge1, edge2]
    )
```