[Canonical page](<https://docs.dhtmlx.com/planning-engine/net/api/core/project/subtree/>)
[Full documentation index](<https://docs.dhtmlx.com/planning-engine/llms.txt>)


# Subtree

The scope of a scoped run. Set it as `Subtree` in [`SolveOptions`](<https://docs.dhtmlx.com/planning-engine/net/api/core/project/solve-options.md>) or [`PreviewOptions`](<https://docs.dhtmlx.com/planning-engine/net/api/core/project/preview-options.md>) to reschedule one task's branch instead of the whole project. Create it with `new Subtree(task)`, and add an object initializer to set `Inclusive` yourself.

## Declaration

```csharp
namespace Plen;

public sealed class Subtree : IDeepCloneable<Subtree>, IEquatable<Subtree>
```

`Subtree` has no parameterless constructor: `Task` is `required`.

## Constructors

### Subtree(Id)

```csharp
public Subtree(Id task)
```

Creates a scope rooted at `task` with `Inclusive = true`.

**Parameters**

| Name | Type | Description |
|---|---|---|
| `task` | [`Id`](<https://docs.dhtmlx.com/planning-engine/net/api/core/data/id.md>) | Root task ID. A `string`, `double` or `int` converts implicitly. |

## Properties

| Property | Type | Default | Description |
|---|---|---|---|
| `Task` | [`Id`](<https://docs.dhtmlx.com/planning-engine/net/api/core/data/id.md>) | required | Root task of the scope. The scope covers this task, its ancestors and descendants, and every task reached from them through outgoing links, transitively. Each task reached this way brings its own ancestors and descendants. |
| `Inclusive` | `bool` | `true` | `true` also follows incoming links, so the scope takes in predecessors and their branches too. `false` follows outgoing links only. |

## Methods

### DeepClone

```csharp
public Subtree DeepClone()
```

Returns a copy with the same `Task` and `Inclusive`.

### Equals

```csharp
public bool Equals(Subtree? other)
```

Value equality: two scopes are equal when `Task` and `Inclusive` are equal. `GetHashCode` follows the same fields, so two `SolveOptions` with equal scopes compare equal.

### ToString

```csharp
public override string ToString()
```

Returns a readable rendering of `Task` and `Inclusive`, for logging.

## Errors

A `Task` that's unknown or not scheduled makes the call that receives the options throw [`InputException`](<https://docs.dhtmlx.com/planning-engine/net/api/core/errors/input-exception.md>) with `Kind = InputErrorKind.Validation` and `Path = "subtree.task"`.

## Example

```csharp
using Plen;

// `project` already holds solved data with a task "2".
static ScheduleResult RescheduleBranch(Project project)
{
    var options = new SolveOptions
    {
        Subtree = new Subtree("2") { Inclusive = false },
    };
    return project.Solve(null, options);
}
```

## Related

- [`SolveOptions`](<https://docs.dhtmlx.com/planning-engine/net/api/core/project/solve-options.md>) - set `Subtree` to scope a solve
- [`PreviewOptions`](<https://docs.dhtmlx.com/planning-engine/net/api/core/project/preview-options.md>) - set `Subtree` to scope a preview
- [Reschedule a branch](<https://docs.dhtmlx.com/planning-engine/net/how-to/reschedule-a-branch.md>) - rescheduling one task's branch step by step
- [Load all task dates](<https://docs.dhtmlx.com/planning-engine/net/how-to/load-all-task-dates.md>) - full date lists with a scoped run
