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

# layout_network

> Compute a force-directed graph layout with a fast forceAtlas2 implementation. 

## Usage

The following example shows how the step can be used in a recipe.

<Accordion title="Examples" icon="code" defaultOpen="true">
  <Tabs>
    <Tab title="Example 1">
      For a weighted layout provide both input columns, e.g.

      ```stan theme={null}
      layout_network(ds.link_targets, ds.link_weights, {scalingRatio: 0.8, linLogMode: false}) -> (ds.x, ds.y)
      ```
    </Tab>

    <Tab title="Signature">
      General syntax for using the step in a recipe. Shows the inputs and outputs the step is expected to receive and will produce respectively. For futher details see sections below.

      ```stan theme={null}
      layout_network(targets: list[number], *weights: list[number], {
          "param": value,
          ...
      }) -> (x: column, y: column)
      ```
    </Tab>
  </Tabs>
</Accordion>

## Inputs & Outputs

The following are the inputs expected by the step and the outputs it produces. These are generally
columns (`ds.first_name`), datasets (`ds` or `ds[["first_name", "last_name"]]`) or models (referenced
by name e.g. `"churn-clf"`).

<Accordion title="Inputs" icon="right-to-bracket">
  <ParamField path="targets" type="column[list[number]]" required>
    A column containing link targets. Source is implied in the index.
  </ParamField>

  <ParamField path="*weights" type="column[list[number]]" />
</Accordion>

<Accordion title="Outputs" icon="right-from-bracket">
  <ParamField path="x" type="column" required>
    A column containing the x coordinate of each node's position in the network.
  </ParamField>

  <ParamField path="y" type="column" required>
    A column containing the y coordinate of each node's position in the network.
  </ParamField>
</Accordion>

## Configuration

The following parameters can be used to configure the behaviour of the step by including them in
a json object as the last "input" to the step, i.e. `step(..., {"param": "value", ...}) -> (output)`.

<Accordion title="Parameters" defaultOpen="true" icon="sliders">
  <ParamField path="gravity" type="number" default="0.05">
    Attracts nodes to the center.
    Prevents islands from drifting away.

    <Accordion title="Examples">
      * 0.05
    </Accordion>
  </ParamField>

  <ParamField path="scalingRatio" type="number" default="0.8">
    The amount of repulsion.
    Greater values lead to a larger and more sparse graph.

    <Accordion title="Examples">
      * 0.8
    </Accordion>
  </ParamField>

  <ParamField path="barnesHutTheta" type="number" default="1.0">
    Algorithmic "resolution".
    Greater values lead to faster execution at the expense of less precise calculations.

    Values must be in the following range:

    ```javascript theme={null}
    0.0 ≤ barnesHutTheta ≤ 2.0
    ```
  </ParamField>

  <ParamField path="avoidHubs" type="boolean" default="false">
    Prefer authorities over hubs.
    Prefer "authorities" (nodes with a high indegree) over hubs (nodes with a high outdegree). Authorities will have more central and hubs more peripheral positions. (default=false).

    <Accordion title="Examples">
      * False
    </Accordion>
  </ParamField>

  <ParamField path="linLogMode" type="boolean" default="false">
    Usually produces tighter clusters.
    Enabling it may also require adjusting the scalingRatio.

    <Accordion title="Examples">
      * False
    </Accordion>
  </ParamField>

  <ParamField path="avoidOverlap" type="boolean" default="false">
    Try to avoid overlap between nodes.

    <Accordion title="Examples">
      * False
    </Accordion>
  </ParamField>

  <ParamField path="iterations" type="integer" default="500">
    The more the better, though it will take longer.

    <Accordion title="Examples">
      * 300
    </Accordion>
  </ParamField>

  <ParamField path="nodeSize" type="number" default="1.0">
    How much space to (try and) give each node in the final layout.

    Values must be in the following range:

    ```javascript theme={null}
    1.0 ≤ nodeSize < inf
    ```
  </ParamField>

  <ParamField path="ignoreWeightsBelow" type="number" default="0.0">
    Links with weights below this value will be ignored.

    Values must be in the following range:

    ```javascript theme={null}
    0.0 ≤ ignoreWeightsBelow < inf
    ```
  </ParamField>

  <ParamField path="normalizeWeights" type="boolean" default="false">
    Normalize weights to the range \[0, 1].
  </ParamField>
</Accordion>
