# GraphClusterRule

Describes one structural or host-defined clustering step.

 Class  

`ChartForgeX.Interactivity`

**Namespace**

`ChartForgeX.Interactivity`

**Assembly**

`ChartForgeX.Interactivity`

**Source**

[GraphClusterRule.cs:64](https://github.com/EvotecIT/ChartForgeX/blob/main/ChartForgeX.Interactivity/GraphClusterRule.cs#L64)

**Modifiers**

sealed

Describes one structural or host-defined clustering step. Rules run in list order when the scene is rendered, after declared clusters, and each rule only takes nodes that no earlier cluster already holds.

## Inheritance

- object
- GraphClusterRule

## Usage

 Explore 21 API references to this type 

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

### Returned or exposed by 11

- Property [GraphClusterOptions.Rules](/api/chartforgex-interactivity-graphclusteroptions/#property-rules)
- Extension method [GraphClusterRule.Collapsed](/api/chartforgex-interactivity-graphclusterrule/#extension-collapsed-chartforgex-interactivity-graphclusterrule-boolean)
- Extension method [GraphClusterRule.Kind](/api/chartforgex-interactivity-graphclusterrule/#extension-kind-chartforgex-interactivity-graphclusterrule-string)
- Extension method [GraphClusterRule.Label](/api/chartforgex-interactivity-graphclusterrule/#extension-label-chartforgex-interactivity-graphclusterrule-string)
- Method [GraphClusterRule.Connections](/api/chartforgex-interactivity-graphclusterrule/#method-connections-string-func-chartforgex-interactivity-graphscenenode-system-boolean-string)
- Method [GraphClusterRule.Hubs](/api/chartforgex-interactivity-graphclusterrule/#method-hubs-int32-func-chartforgex-interactivity-graphscenenode-system-boolean-string)
- Method [GraphClusterRule.Outliers](/api/chartforgex-interactivity-graphclusterrule/#method-outliers-func-chartforgex-interactivity-graphscenenode-system-boolean-string)
- Method [GraphClusterRule.Where](/api/chartforgex-interactivity-graphclusterrule/#method-where-string-string-func-chartforgex-interactivity-graphscenenode-system-boolean)
- Method [GraphClusterRuleFluent.Collapsed](/api/chartforgex-interactivity-graphclusterrulefluent/#method-collapsed-chartforgex-interactivity-graphclusterrule-boolean)
- Method [GraphClusterRuleFluent.Kind](/api/chartforgex-interactivity-graphclusterrulefluent/#method-kind-chartforgex-interactivity-graphclusterrule-string)
- Method [GraphClusterRuleFluent.Label](/api/chartforgex-interactivity-graphclusterrulefluent/#method-label-chartforgex-interactivity-graphclusterrule-string)

### Accepted by parameters 10

- Extension method [GraphClusterOptions.Rule](/api/chartforgex-interactivity-graphclusteroptions/#extension-rule-chartforgex-interactivity-graphclusteroptions-chartforgex-interactivity-graphclusterrule) parameter `item`
- Extension method [GraphClusterOptions.Rules](/api/chartforgex-interactivity-graphclusteroptions/#extension-rules-chartforgex-interactivity-graphclusteroptions-collections-generic-ienumerable-chartforgex-interactivity-graphclusterrule) parameter `items`
- Method [GraphClusterOptionsFluent.Rule](/api/chartforgex-interactivity-graphclusteroptionsfluent/#method-rule-chartforgex-interactivity-graphclusteroptions-chartforgex-interactivity-graphclusterrule) parameter `item`
- Method [GraphClusterOptionsFluent.Rules](/api/chartforgex-interactivity-graphclusteroptionsfluent/#method-rules-chartforgex-interactivity-graphclusteroptions-collections-generic-ienumerable-chartforgex-interactivity-graphclusterrule) parameter `items`
- Extension method [GraphClusterRule.Collapsed](/api/chartforgex-interactivity-graphclusterrule/#extension-collapsed-chartforgex-interactivity-graphclusterrule-boolean) parameter `graphClusterRule`
- Extension method [GraphClusterRule.Kind](/api/chartforgex-interactivity-graphclusterrule/#extension-kind-chartforgex-interactivity-graphclusterrule-string) parameter `graphClusterRule`
- Extension method [GraphClusterRule.Label](/api/chartforgex-interactivity-graphclusterrule/#extension-label-chartforgex-interactivity-graphclusterrule-string) parameter `graphClusterRule`
- Method [GraphClusterRuleFluent.Collapsed](/api/chartforgex-interactivity-graphclusterrulefluent/#method-collapsed-chartforgex-interactivity-graphclusterrule-boolean) parameter `graphClusterRule`
- Method [GraphClusterRuleFluent.Kind](/api/chartforgex-interactivity-graphclusterrulefluent/#method-kind-chartforgex-interactivity-graphclusterrule-string) parameter `graphClusterRule`
- Method [GraphClusterRuleFluent.Label](/api/chartforgex-interactivity-graphclusterrulefluent/#method-label-chartforgex-interactivity-graphclusterrule-string) parameter `graphClusterRule`

 Filter members   

    Show inherited   

 

## Methods

 `public static GraphClusterRule Connections(string nodeId, Func<GraphSceneNode, bool>? neighbourFilter = null, string idPrefix = "connection")` [#](#method-connections-string-func-chartforgex-interactivity-graphscenenode-system-boolean-string) 

[GraphClusterRule.cs:95](https://github.com/EvotecIT/ChartForgeX/blob/main/ChartForgeX.Interactivity/GraphClusterRule.cs#L95)

Creates a rule that clusters one node with its not yet clustered neighbours.

Parameters

**nodeId string required**

The node to start from.

**neighbourFilter System.Func<ChartForgeX.Interactivity.GraphSceneNode, bool>? = null optional**

Optional test a neighbour must pass to join.

**idPrefix string = "connection" optional**

The cluster id prefix.

Returns

 `GraphClusterRule` 

 `public static GraphClusterRule Hubs(int minimumConnections = 3, Func<GraphSceneNode, bool>? neighbourFilter = null, string idPrefix = "hub")` [#](#method-hubs-int32-func-chartforgex-interactivity-graphscenenode-system-boolean-string) 

[GraphClusterRule.cs:76](https://github.com/EvotecIT/ChartForgeX/blob/main/ChartForgeX.Interactivity/GraphClusterRule.cs#L76)

Creates a rule that clusters each node with at least minimumConnections distinct neighbours together with those neighbours. Hubs are taken from the most connected down, ties by id.

Parameters

**minimumConnections int = 3 optional**

The connection count that makes a node a hub. Must be at least two.

**neighbourFilter System.Func<ChartForgeX.Interactivity.GraphSceneNode, bool>? = null optional**

Optional test a neighbour must pass to join its hub.

**idPrefix string = "hub" optional**

The cluster id prefix.

Returns

 `GraphClusterRule` 

 `public static GraphClusterRule Outliers(Func<GraphSceneNode, bool>? leafFilter = null, string idPrefix = "outliers")` [#](#method-outliers-func-chartforgex-interactivity-graphscenenode-system-boolean-string) 

[GraphClusterRule.cs:86](https://github.com/EvotecIT/ChartForgeX/blob/main/ChartForgeX.Interactivity/GraphClusterRule.cs#L86)

Creates a rule that clusters leaf nodes (exactly one distinct neighbour) with that neighbour, one cluster per neighbour.

Parameters

**leafFilter System.Func<ChartForgeX.Interactivity.GraphSceneNode, bool>? = null optional**

Optional test a leaf must pass to join.

**idPrefix string = "outliers" optional**

The cluster id prefix.

Returns

 `GraphClusterRule` 

 `public static GraphClusterRule Where(string id, string label, Func<GraphSceneNode, bool> predicate)` [#](#method-where-string-string-func-chartforgex-interactivity-graphscenenode-system-boolean) 

[GraphClusterRule.cs:64](https://github.com/EvotecIT/ChartForgeX/blob/main/ChartForgeX.Interactivity/GraphClusterRule.cs#L64)

Creates a rule that groups every not yet clustered node the predicate accepts into one cluster. The predicate runs in .NET while the page is built, so the result is part of the static document.

Parameters

**id string required**

The stable cluster id.

**label string required**

The cluster label.

**predicate System.Func<ChartForgeX.Interactivity.GraphSceneNode, bool> required**

The membership test.

Returns

 `GraphClusterRule` 

## Inherited Methods

 `public virtual bool Equals(object? obj)` [#](#method-equals-object) 

Inherited from object

Parameters

**obj object? required**

Returns

 `bool` 

 `public virtual int GetHashCode()` [#](#method-gethashcode) 

Inherited from object

Returns

 `int` 

 `public Type GetType()` [#](#method-gettype) 

Inherited from object

Returns

 `Type` 

 `public virtual string? ToString()` [#](#method-tostring) 

Inherited from object

Returns

 `string?` 

## Properties

 `public GraphClusterRuleKind RuleKind { get; }` [#](#property-rulekind) 

[GraphClusterRule.cs:27](https://github.com/EvotecIT/ChartForgeX/blob/main/ChartForgeX.Interactivity/GraphClusterRule.cs#L27)

Gets what the rule groups.

 `public string Id { get; }` [#](#property-id) 

[GraphClusterRule.cs:33](https://github.com/EvotecIT/ChartForgeX/blob/main/ChartForgeX.Interactivity/GraphClusterRule.cs#L33)

Gets the rule id. Predicate rules use it as the cluster id; hub, outlier and connection rules use it as the prefix of ids such as hub-dc01, so the same graph always produces the same cluster ids.

 `public int MinimumConnections { get; }` [#](#property-minimumconnections) 

[GraphClusterRule.cs:36](https://github.com/EvotecIT/ChartForgeX/blob/main/ChartForgeX.Interactivity/GraphClusterRule.cs#L36)

Gets the connection count a node needs to become a hub. Only used by [GraphClusterRuleKind.Hubs](/api/chartforgex-interactivity-graphclusterrulekind/).

 `public string? NodeId { get; private set; }` [#](#property-nodeid) 

[GraphClusterRule.cs:39](https://github.com/EvotecIT/ChartForgeX/blob/main/ChartForgeX.Interactivity/GraphClusterRule.cs#L39)

Gets the node id a connection rule starts from. Only used by [GraphClusterRuleKind.Connections](/api/chartforgex-interactivity-graphclusterrulekind/).

 `public Func<GraphSceneNode, bool>? Predicate { get; }` [#](#property-predicate) 

[GraphClusterRule.cs:45](https://github.com/EvotecIT/ChartForgeX/blob/main/ChartForgeX.Interactivity/GraphClusterRule.cs#L45)

Gets the node test. Predicate rules use it for membership; the structural rules use it, when set, to decide which neighbours may join (the hub, anchor or start node itself always joins).

 `public string? Label { get; set; }` [#](#property-label) 

[GraphClusterRule.cs:48](https://github.com/EvotecIT/ChartForgeX/blob/main/ChartForgeX.Interactivity/GraphClusterRule.cs#L48)

Gets or sets the cluster label. Predicate rules default to the rule id; structural rules default to the hub, anchor or start node label.

 `public string? Kind { get; set; }` [#](#property-kind) 

[GraphClusterRule.cs:51](https://github.com/EvotecIT/ChartForgeX/blob/main/ChartForgeX.Interactivity/GraphClusterRule.cs#L51)

Gets or sets the cluster kind written to the produced clusters. Defaults to hub, outlier, connection or group.

 `public bool Collapsed { get; set; }` [#](#property-collapsed) 

[GraphClusterRule.cs:54](https://github.com/EvotecIT/ChartForgeX/blob/main/ChartForgeX.Interactivity/GraphClusterRule.cs#L54)

Gets or sets whether the produced clusters start collapsed.

## Extension Methods

 `public static GraphClusterRule Collapsed(GraphClusterRule graphClusterRule, bool value = true)` [#](#extension-collapsed-chartforgex-interactivity-graphclusterrule-boolean) 

Sets [GraphClusterRule.Collapsed](/api/chartforgex-interactivity-graphclusterrule/): Gets or sets whether the produced clusters start collapsed.

Parameters

**graphClusterRule ChartForgeX.Interactivity.GraphClusterRule required**

The instance.

**value bool = true optional**

The value; true when omitted.

Returns

 `GraphClusterRule` The same instance. 

Examples

```csharp
// C# initializer or property          // C# fluent
graphClusterRule.Collapsed = value;    graphClusterRule.Collapsed(value);
```

 `public static GraphClusterRule Kind(GraphClusterRule graphClusterRule, string? value)` [#](#extension-kind-chartforgex-interactivity-graphclusterrule-string) 

Sets [GraphClusterRule.Kind](/api/chartforgex-interactivity-graphclusterrule/): Gets or sets the cluster kind written to the produced clusters. Defaults to hub, outlier, connection or group.

Parameters

**graphClusterRule ChartForgeX.Interactivity.GraphClusterRule required**

The instance.

**value string? required**

The value.

Returns

 `GraphClusterRule` The same instance. 

Examples

```csharp
// C# initializer or property     // C# fluent
graphClusterRule.Kind = value;    graphClusterRule.Kind(value);
```

 `public static GraphClusterRule Label(GraphClusterRule graphClusterRule, string? value)` [#](#extension-label-chartforgex-interactivity-graphclusterrule-string) 

Sets [GraphClusterRule.Label](/api/chartforgex-interactivity-graphclusterrule/): Gets or sets the cluster label. Predicate rules default to the rule id; structural rules default to the hub, anchor or start node label.

Parameters

**graphClusterRule ChartForgeX.Interactivity.GraphClusterRule required**

The instance.

**value string? required**

The value.

Returns

 `GraphClusterRule` The same instance. 

Examples

```csharp
// C# initializer or property      // C# fluent
graphClusterRule.Label = value;    graphClusterRule.Label(value);
```

<!-- PowerForge markdown artifact sha256:18B2A5E7623950206DE5A53862E36BA3F9303C063166032BD520FE3EA49B7DE9 -->
