> ## Documentation Index
> Fetch the complete documentation index at: https://docs.factagora.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Causality Graph

> Causality Graph 활용 베스트 프랙티스

## 분석적이거나 인과 관계가 담긴 콘텐츠의 URL 사용

명시적인 인과 표현(예: "leads to", "causes", "results in")이 담긴 연구 보고서, 뉴스 기사, 정책 문서를 가리키는 URL이 더 풍부하고 정확한 그래프를 만듭니다.

```json theme={null}
{ "url": "https://imf.org/en/Publications/WEO" }
```

로컬에 있는 문서라면 `/api/v1/causality-graph/file` 엔드포인트를 대신 사용하세요.

```bash theme={null}
curl -X POST "https://api.factagora.com/api/v1/causality-graph/file" \
  -H "Authorization: Bearer fag_your_api_key" \
  -F "file=@analysis.pdf"
```

## 방향성 그래프로 시각화

`edges` 배열은 방향성이 있습니다: `from`은 원인, `to`는 결과입니다. 이를 활용해 UI에서 DAG(방향성 비순환 그래프)로 렌더링하세요.

```javascript theme={null}
edges.forEach(edge => {
  graph.addEdge(edge.from, edge.to, { label: edge.label });
});
```

## 고립된 노드 필터링

간선이 없는 노드는 추출 과정의 잔여물일 가능성이 높습니다. 렌더링 전에 필터링하세요.

```javascript theme={null}
const connectedNodeIds = new Set([
  ...edges.map(e => e.from),
  ...edges.map(e => e.to),
]);
const filteredNodes = nodes.filter(n => connectedNodeIds.has(n.id));
```

## Timeseries와 결합

Causality Graph를 [Timeseries](/ko/api-reference/timeseries)와 함께 사용해 "무엇이 일어났는가?"와 "왜 일어났는가?"에 모두 답하세요.

```
Timeseries (무엇이 일어났는가) → Causality Graph (왜 일어났는가)
```
