> For the complete documentation index, see [llms.txt](https://docs.rootcause.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rootcause.ai/api-and-integrations/sdk-getting-started/sdk-api-reference/graph.md).

# Graph

Discovered causal graphs, and the domain knowledge pinned onto them.

## Graph

The causal graph of a twin version: edges, adjacency, and domain-knowledge pins.

### Properties

* **nodes** (`list[str]`)
* **edges** (`pd.DataFrame`)

### Graph.refresh

```python
Graph.refresh() -> Graph
```

*Undocumented; the signature above is the contract.*

### Graph.link

```python
Graph.link() -> Any
```

The twin page this graph is drawn on, as a clickable URL.

### Graph.adjacency

```python
Graph.adjacency(values: str = 'strength') -> pd.DataFrame
```

Adjacency matrix as a labelled DataFrame.

| Parameter | Type  | Default      | Description                                          |
| --------- | ----- | ------------ | ---------------------------------------------------- |
| `values`  | `str` | `'strength'` | What each cell holds: `strength`, `sign`, or `bool`. |

**Returns** (`pd.DataFrame`): A square DataFrame indexed by cause and labelled by effect.

### Graph.to\_numpy

```python
Graph.to_numpy(values: str = 'strength')
```

*Undocumented; the signature above is the contract.*

### Graph.to\_networkx

```python
Graph.to_networkx()
```

*Undocumented; the signature above is the contract.*

### Graph.pin

```python
Graph.pin(cause: str, effect: str) -> Graph
```

Fix an edge as present: domain knowledge the next discovery run must honour.

| Parameter | Type  | Default  | Description            |
| --------- | ----- | -------- | ---------------------- |
| `cause`   | `str` | required | The causing variable.  |
| `effect`  | `str` | required | The affected variable. |

**Returns** (`Graph`): This graph, refreshed.

### Graph.forbid

```python
Graph.forbid(cause: str, effect: str) -> Graph
```

Fix an edge as absent (anti-edge).

| Parameter | Type  | Default  | Description            |
| --------- | ----- | -------- | ---------------------- |
| `cause`   | `str` | required | The causing variable.  |
| `effect`  | `str` | required | The affected variable. |

**Returns** (`Graph`): This graph, refreshed.

### Graph.train

```python
Graph.train(*, timeout: float = 7200.0) -> Twin
```

*Undocumented; the signature above is the contract.*
