{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://schema.rtemis.org/clustering/v1/schema.json",
  "title": "rtemis ClusteringConfig",
  "description": "Language-independent config for an rtemis clustering run. Mirrors the `ClusteringConfig` object: an algorithm name and an algorithm-specific `config`. The same config drives rtemis (R), rtemis-py, and rtemislive to identical output.",
  "type": "object",
  "required": ["algorithm", "config"],
  "additionalProperties": false,
  "properties": {
    "$schema": {
      "type": "string",
      "const": "https://schema.rtemis.org/clustering/v1/schema.json",
      "description": "JSON Schema URI for this config instance."
    },
    "algorithm": {
      "type": "string",
      "enum": ["KMeans", "HardCL", "NeuralGas", "CMeans", "DBSCAN"],
      "description": "Clustering algorithm name."
    },
    "config": {
      "type": "object",
      "description": "Variant-specific parameters. Validated per `algorithm` below."
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "algorithm": {
            "const": "KMeans"
          }
        },
        "required": ["algorithm"]
      },
      "then": {
        "properties": {
          "config": {
            "$ref": "https://schema.rtemis.org/clustering/kmeans/v1/schema.json"
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "algorithm": {
            "const": "HardCL"
          }
        },
        "required": ["algorithm"]
      },
      "then": {
        "properties": {
          "config": {
            "$ref": "https://schema.rtemis.org/clustering/hardcl/v1/schema.json"
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "algorithm": {
            "const": "NeuralGas"
          }
        },
        "required": ["algorithm"]
      },
      "then": {
        "properties": {
          "config": {
            "$ref": "https://schema.rtemis.org/clustering/neuralgas/v1/schema.json"
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "algorithm": {
            "const": "CMeans"
          }
        },
        "required": ["algorithm"]
      },
      "then": {
        "properties": {
          "config": {
            "$ref": "https://schema.rtemis.org/clustering/cmeans/v1/schema.json"
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "algorithm": {
            "const": "DBSCAN"
          }
        },
        "required": ["algorithm"]
      },
      "then": {
        "properties": {
          "config": {
            "$ref": "https://schema.rtemis.org/clustering/dbscan/v1/schema.json"
          }
        }
      }
    }
  ]
}
