Skip to content
Konstantinos N. Vavliakis edited this page Aug 21, 2013 · 6 revisions

RESTful protocol for Clustering a Consumer Social Network.

Various clustering algorithm can be applied in a CSN graph .

Cluster a CSN Graph

POST /api/csnclusters | create

Creates a new CSN Clustering based on the cluster creation parameters. Schema: ClusterParameters.schema.schema

example:

curl -k -i --data @clusterparams.json --header Content-type:application/json https://localhost:8443/cassandra/api/csnclusters

Consumes: Route, JSON

{
        "name" : "ClusterParameters",
        "graph_id" : "5200dd72e4b00ecc4cce457d",
        "clustermethod" : "kmeans",
        "clusterbasedon" : "hoursE",
        "n": 2
}
 
 

Produces: JSON

{
  "success": true,
  "message": "Clusters Created",
  "data": {
    "method": "kmeans",
    "_id": "5200ee37e4b0665d70a58f08",
    "graph_id": "5200dd72e4b00ecc4cce457d",
    "run_id": "f",
    "n": 2,
    "cluster_0": [
      "5200dd72e4b00ecc4cce4580"
    ],
    "cluster_1": [
      "5200dd72e4b00ecc4cce457e",
      "5200dd72e4b00ecc4cce457f"
    ]
  }

READ CSN Clusters

GET /api/csnclusters |  index

example:

curl -k -i --header Content-type:application/json 'https://localhost:8443/cassandra/api/csnclusters?run_id=f'

Retrieves the CSN clusters for a Run

Consumes: Route, Parameter

Produces: JSON

{
  "success": true,
  "message": "CSN clusters retrieved successfully",
  "size": 3,
  "data": [
    {
      "_id": "51dd2b87e4b06c9eb5702d9e",
      "method": "kmeans",
      "graph_id": "51dd2b63e4b06c9eb5702cf9",
      "n": 4
    },
    {
      "_id": "51dd2e10e4b080a6f1ea30cd",
      "method": "kmeans",
      "graph_id": "51dd2b63e4b06c9eb5702cf9",
      "n": 4
    },
    {
      "_id": "51dd7177e4b028fa3a1c0ea4",
      "method": "kmeans",
      "graph_id": "51dd2b63e4b06c9eb5702cf9",
      "n": 4
    }
}

READ CSN Edges Removed (Only for Edgebetweenness clusterer)

GET /api/csnedgesremoved |  index

example:

curl -k -i --header Content-type:application/json 'https://localhost:8443/cassandra/api/csnedgesremoved/51dd99ece4b00484089d9f5d'

Retrieves the CSN edges removed from the Edgebetweennness clusterer

Consumes: Route, Parameter

Produces: JSON

{
  "success": true,
  "message": "CSN edges removed from edge betweenness clusterer retrieved successfully",
  "size": 4,
  "data": [
    {
      "_id": "51dd99ece4b00484089d9f7f",
      "edge_id": "51dd2b66e4b06c9eb5702d24",
      "graph_id": "51dd2b63e4b06c9eb5702cf9",
      "clustersid": "51dd99ece4b00484089d9f5d"
    },
    {
      "_id": "51dd99ece4b00484089d9f80",
      "edge_id": "51dd2b67e4b06c9eb5702d43",
      "graph_id": "51dd2b63e4b06c9eb5702cf9",
      "clustersid": "51dd99ece4b00484089d9f5d"
    },
    {
      "_id": "51dd99ece4b00484089d9f81",
      "edge_id": "51dd2b67e4b06c9eb5702d79",
      "graph_id": "51dd2b63e4b06c9eb5702cf9",
      "clustersid": "51dd99ece4b00484089d9f5d"
    },
    {
      "_id": "51dd99ece4b00484089d9f82",
      "edge_id": "51dd2b67e4b06c9eb5702d3f",
      "graph_id": "51dd2b63e4b06c9eb5702cf9",
      "clustersid": "51dd99ece4b00484089d9f5d"
    }
  ]
}

DELETE Clustering

DELETE /api/csnclusters_id/{csncluster_id} | delete

READ CSN Clustering

GET /api/csnclusters/{csnclusters_id} | show

Fetches the properties of the CSN Clustering.

example: curl -k -i --header Content-type:application/json 'https://localhost:8443/cassandra/api/csnclusters/51da9206e4b0def72b1e65b8'

Consumes: Route

Produces: JSON

{
  "success": true,
  "message": "CSN cluster retrieved successfully",
  "size": 1,
  "data": [
    {
      "_id": "51e43bd3e4b0826b7fc71a12",
      "method": "kmeans",
      "graph_id": "51e42dbae4b0826b7fc71a0d",
      "n": 2,
      "cluster_0": [
        "51e42dbae4b0826b7fc71a10"
      ],
      "cluster_1": [
        "51e42dbae4b0826b7fc71a0e",
        "51e42dbae4b0826b7fc71a0f"
      ]
    }
  ]
}

READ ClusterID of a node

GET /api/csnclusterofnode |  index

example:

curl -k -i --header Content-type:application/json 'https://localhost:8443/cassandra/api/csnclusterofnode?csnnode_id=51dd2b65e4b06c9eb5702d09&clusters_id=51dd2e10e4b080a6f1ea30cd'

Retrieves the CSN cluster for an Installation

Consumes: Route, Parameter

Produces: JSON

{
  "success": true,
  "message": "CSN cluster of node retrieved successfully",
  "size": 1,
  "data": [
    {
      "_id": "51dd2e10e4b080a6f1ea30d2",
      "node_id": "51dd2b65e4b06c9eb5702d09",
      "cluster": "cluster_0",
      "graph_id": "51dd2b63e4b06c9eb5702cf9",
      "clustersid": "51dd2e10e4b080a6f1ea30cd"
    }
  ]
}

Deletes the existing Clustering .

example:

curl -i -k -X DELETE 'https://localhost:8443/cassandra/api/csnclusters/51da9206e4b0def72b1e65b8'

Consumes: Route

Produces: Delete status

ClusterParameters Schema

{
    "name": "ClusterParameters",
    "type": "object",
    "description": "Cluster parameters to cluster a graph",
    "properties": {
        "name": {
            "type": "string",
            "description": "Name",
            "optional": true
        },
        "clusterbasedon": {
            "type": "string",
            "description": "The clustering method to be used",
               "enum": [
                    "TotalConsumptionP",
                    "AverageConsumptionP",
                    "MinConsumptionP",
                    "MaxConsumptionP",

                    "TotalConsumptionQ",
                    "AverageConsumptionQ",
                    "MinConsumptionQ",
                    "MaxConsumptionQ",

                    "ConsumptionPerHourP",
                    "ConsumptionPerHourQ"
            ],
            "optional": true
        },    
        "clustermethod": {
            "type": "string",
            "description": "Clustering method",
            "enum": [
                    "kmeans",
                    "hierarchical",
                    "graphedgebetweenness"
            ],
            "optional": false
        },
        "graph_id": {
            "type": "string",
            "description": "The graph the cluster assignment belongs",
            "optional": false
        },
        "n": {
            "type": "integer",
            "description": "Total number of clusters to create",
            "optional": false
        }
     },
    "additionalProperties" : false
}