> ## 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.

# link_rows_by_rownum

> Create network links using explicit lists of target row numbers and optional weights. 

This step essentially just adds metadata to the input columns to ensure Graphext knows
that these columns define network links and that they belong to the same set of links
(there can be multiple "layers" of links in the same dataset). But it also makes sure
all links are valid. E.g. that they don't refer to rows that don't exist, that attributes
match the number of target rows etc.

## 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">
      To simply link rows using a default weight of 1.0

      ```stan theme={null}
      link_rows_by_rownum(ds.targets_in, ds.weights_in) -> (ds.valid_targets, ds.valid_weights)
      ```
    </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}
      link_rows_by_rownum(targets_in: number|list[number], *attrs_in: column, {
          "param": value,
          ...
      }) -> (targets_out: column, *attrs_out: 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_in" type="column[number|list[number]]" required>
    A column of lists containing numeric IDs corresponding to the rows acting as the targets of links.
  </ParamField>

  <ParamField path="*attrs_in" type="column">
    Optional corresponding lists of weights and/or other attributes for those targets.
  </ParamField>
</Accordion>

<Accordion title="Outputs" icon="right-from-bracket">
  <ParamField path="targets_out" type="column" required>
    Column containing new targets.
  </ParamField>

  <ParamField path="*attrs_out" type="column">
    If optional inputs were provided, new weight/attribute columns between connected nodes.
  </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="weight_column" type="[string, null]" required>
    Name of the column acting as the weights of the links.
    Must refer to one of the optional columns passed to the step. If `null`, an extra
    output column will be created containing a weight of 1.0 for each link defined in
    the target column (unless a `weight_factor` is applied, in which the weights will
    have the corresponding value, see below).
  </ParamField>

  <ParamField path="weight_factor" type="number" default="1.0">
    Multiply link weights by this number.
    If an input column with weights was identified using `weight_column`, the values
    in that column will be multiplied by this factor. If no weights were passed in,
    the newly added weights will all have this value.
  </ParamField>
</Accordion>
